]> git.lizzy.rs Git - rust.git/blob - src/mod.rs
Trivial reformatting
[rust.git] / src / mod.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(box_syntax)]
12 #![feature(box_patterns)]
13 #![feature(rustc_private)]
14 #![feature(collections)]
15 #![feature(exit_status)]
16 #![feature(str_char)]
17
18 // TODO we're going to allocate a whole bunch of temp Strings, is it worth
19 // keeping some scratch mem for this and running our own StrPool?
20 // TODO for lint violations of names, emit a refactor script
21
22 // TODO priorities
23 // Fix fns and methods properly
24 //   dead spans
25 //
26 // Smoke testing till we can use it
27 //   end of multi-line string has wspace
28 //   no newline at the end of doc.rs
29
30 #[macro_use]
31 extern crate log;
32
33 extern crate getopts;
34 extern crate rustc;
35 extern crate rustc_driver;
36 extern crate syntax;
37
38 extern crate strings;
39
40 use rustc::session::Session;
41 use rustc::session::config::{self, Input};
42 use rustc_driver::{driver, CompilerCalls, Compilation};
43
44 use syntax::{ast, ptr};
45 use syntax::codemap::{CodeMap, Span, Pos, BytePos};
46 use syntax::diagnostics;
47 use syntax::parse::token;
48 use syntax::print::pprust;
49 use syntax::visit;
50
51 use std::path::PathBuf;
52
53 use changes::ChangeSet;
54 use lists::{write_list, ListFormatting, SeparatorTactic, ListTactic};
55
56 mod changes;
57 mod functions;
58 mod missed_spans;
59 mod lists;
60
61 const IDEAL_WIDTH: usize = 80;
62 const LEEWAY: usize = 5;
63 const MAX_WIDTH: usize = 100;
64 const MIN_STRING: usize = 10;
65 const TAB_SPACES: usize = 4;
66 const FN_BRACE_STYLE: BraceStyle = BraceStyle::SameLineWhere;
67 const FN_RETURN_INDENT: ReturnIndent = ReturnIndent::WithArgs;
68
69 #[derive(Copy, Clone, Eq, PartialEq, Debug)]
70 pub enum WriteMode {
71     Overwrite,
72     // str is the extension of the new file
73     NewFile(&'static str),
74     // Write the output to stdout.
75     Display,
76 }
77
78 #[derive(Copy, Clone, Eq, PartialEq, Debug)]
79 enum BraceStyle {
80     AlwaysNextLine,
81     PreferSameLine,
82     // Prefer same line except where there is a where clause, in which case force
83     // the brace to the next line.
84     SameLineWhere,
85 }
86
87 // How to indent a function's return type.
88 #[derive(Copy, Clone, Eq, PartialEq, Debug)]
89 enum ReturnIndent {
90     // Aligned with the arguments
91     WithArgs,
92     // Aligned with the where clause
93     WithWhereClause,
94 }
95
96 // Formatting which depends on the AST.
97 fn fmt_ast<'a>(krate: &ast::Crate, codemap: &'a CodeMap) -> ChangeSet<'a> {
98     let mut visitor = FmtVisitor::from_codemap(codemap);
99     visit::walk_crate(&mut visitor, krate);
100     let files = codemap.files.borrow();
101     if let Some(last) = files.last() {
102         visitor.format_missing(last.end_pos);
103     }
104
105     visitor.changes
106 }
107
108 // Formatting done on a char by char basis.
109 fn fmt_lines(changes: &mut ChangeSet) {
110     // Iterate over the chars in the change set.
111     for (f, text) in changes.text() {
112         let mut trims = vec![];
113         let mut last_wspace: Option<usize> = None;
114         let mut line_len = 0;
115         let mut cur_line = 1;
116         for (c, b) in text.chars() {
117             if c == '\n' { // TOOD test for \r too
118                 // Check for (and record) trailing whitespace.
119                 if let Some(lw) = last_wspace {
120                     trims.push((cur_line, lw, b));
121                     line_len -= b - lw;
122                 }
123                 // Check for any line width errors we couldn't correct.
124                 if line_len > MAX_WIDTH {
125                     // FIXME store the error rather than reporting immediately.
126                     println!("Rustfmt couldn't fix (sorry). {}:{}: line longer than {} characters",
127                              f, cur_line, MAX_WIDTH);
128                 }
129                 line_len = 0;
130                 cur_line += 1;
131                 last_wspace = None;
132             } else {
133                 line_len += 1;
134                 if c.is_whitespace() {
135                     if last_wspace.is_none() {
136                         last_wspace = Some(b);
137                     }
138                 } else {
139                     last_wspace = None;
140                 }
141             }
142         }
143
144         for &(l, _, _) in trims.iter() {
145             // FIXME store the error rather than reporting immediately.
146             println!("Rustfmt left trailing whitespace at {}:{} (sorry)", f, l);
147         }
148     }
149 }
150
151 struct FmtVisitor<'a> {
152     codemap: &'a CodeMap,
153     changes: ChangeSet<'a>,
154     last_pos: BytePos,
155     // TODO RAII util for indenting
156     block_indent: usize,
157 }
158
159 impl<'a, 'v> visit::Visitor<'v> for FmtVisitor<'a> {
160     fn visit_expr(&mut self, ex: &'v ast::Expr) {
161         debug!("visit_expr: {:?} {:?}",
162                self.codemap.lookup_char_pos(ex.span.lo),
163                self.codemap.lookup_char_pos(ex.span.hi));
164         self.format_missing(ex.span.lo);
165         let offset = self.changes.cur_offset_span(ex.span);
166         let new_str = self.rewrite_expr(ex, MAX_WIDTH - offset, offset);
167         self.changes.push_str_span(ex.span, &new_str);
168         self.last_pos = ex.span.hi;
169     }
170
171     fn visit_block(&mut self, b: &'v ast::Block) {
172         debug!("visit_block: {:?} {:?}",
173                self.codemap.lookup_char_pos(b.span.lo),
174                self.codemap.lookup_char_pos(b.span.hi));
175         self.format_missing(b.span.lo);
176
177         self.changes.push_str_span(b.span, "{");
178         self.last_pos = self.last_pos + BytePos(1);
179         self.block_indent += TAB_SPACES;
180
181         for stmt in &b.stmts {
182             self.format_missing_with_indent(stmt.span.lo);
183             self.visit_stmt(&stmt)
184         }
185         match b.expr {
186             Some(ref e) => {
187                 self.format_missing_with_indent(e.span.lo);
188                 self.visit_expr(e);
189             }
190             None => {}
191         }
192
193         self.block_indent -= TAB_SPACES;
194         // TODO we should compress any newlines here to just one
195         self.format_missing_with_indent(b.span.hi - BytePos(1));
196         self.changes.push_str_span(b.span, "}");
197         self.last_pos = b.span.hi;
198     }
199
200     // Note that this only gets called for function defintions. Required methods
201     // on traits do not get handled here.
202     fn visit_fn(&mut self,
203                 fk: visit::FnKind<'v>,
204                 fd: &'v ast::FnDecl,
205                 b: &'v ast::Block,
206                 s: Span,
207                 _: ast::NodeId) {
208         self.format_missing(s.lo);
209         self.last_pos = s.lo;
210
211         // TODO need to check against expected indent
212         let indent = self.codemap.lookup_char_pos(s.lo).col.0;
213         match fk {
214             visit::FkItemFn(ident, ref generics, ref unsafety, ref abi, vis) => {
215                 let new_fn = self.rewrite_fn(indent,
216                                              ident,
217                                              fd,
218                                              None,
219                                              generics,
220                                              unsafety,
221                                              abi,
222                                              vis);
223                 self.changes.push_str_span(s, &new_fn);
224             }
225             visit::FkMethod(ident, ref sig, vis) => {
226                 let new_fn = self.rewrite_fn(indent,
227                                              ident,
228                                              fd,
229                                              Some(&sig.explicit_self),
230                                              &sig.generics,
231                                              &sig.unsafety,
232                                              &sig.abi,
233                                              vis.unwrap_or(ast::Visibility::Inherited));
234                 self.changes.push_str_span(s, &new_fn);
235             }
236             visit::FkFnBlock(..) => {}
237         }
238
239         self.last_pos = b.span.lo;
240         self.visit_block(b)
241     }
242
243     fn visit_item(&mut self, item: &'v ast::Item) {
244         match item.node {
245             ast::Item_::ItemUse(ref vp) => {
246                 match vp.node {
247                     ast::ViewPath_::ViewPathList(ref path, ref path_list) => {
248                         self.format_missing(item.span.lo);
249                         let new_str = self.rewrite_use_list(path, path_list, vp.span);
250                         self.changes.push_str_span(item.span, &new_str);
251                         self.last_pos = item.span.hi;
252                     }
253                     ast::ViewPath_::ViewPathGlob(_) => {
254                         // FIXME convert to list?
255                     }
256                     _ => {}
257                 }
258                 visit::walk_item(self, item);
259             }
260             ast::Item_::ItemImpl(..) => {
261                 self.block_indent += TAB_SPACES;
262                 visit::walk_item(self, item);
263                 self.block_indent -= TAB_SPACES;
264             }
265             _ => {
266                 visit::walk_item(self, item);
267             }
268         }
269     }
270
271     fn visit_mac(&mut self, mac: &'v ast::Mac) {
272         visit::walk_mac(self, mac)
273     }
274
275     fn visit_mod(&mut self, m: &'v ast::Mod, s: Span, _: ast::NodeId) {
276         // Only visit inline mods here.
277         if self.codemap.lookup_char_pos(s.lo).file.name !=
278            self.codemap.lookup_char_pos(m.inner.lo).file.name {
279             return;
280         }
281         visit::walk_mod(self, m);
282     }
283 }
284
285 impl<'a> FmtVisitor<'a> {
286     fn from_codemap<'b>(codemap: &'b CodeMap) -> FmtVisitor<'b> {
287         FmtVisitor {
288             codemap: codemap,
289             changes: ChangeSet::from_codemap(codemap),
290             last_pos: BytePos(0),
291             block_indent: 0,
292         }
293     }
294
295     fn snippet(&self, span: Span) -> String {
296         match self.codemap.span_to_snippet(span) {
297             Ok(s) => s,
298             Err(_) => {
299                 println!("Couldn't make snippet for span {:?}->{:?}",
300                          self.codemap.lookup_char_pos(span.lo),
301                          self.codemap.lookup_char_pos(span.hi));
302                 "".to_string()
303             }
304         }
305     }
306
307     // TODO NEEDS TESTS
308     fn rewrite_string_lit(&mut self, s: &str, span: Span, width: usize, offset: usize) -> String {
309         // FIXME I bet this stomps unicode escapes in the source string
310
311         // Check if there is anything to fix: we always try to fixup multi-line
312         // strings, or if the string is too long for the line.
313         let l_loc = self.codemap.lookup_char_pos(span.lo);
314         let r_loc = self.codemap.lookup_char_pos(span.hi);
315         if l_loc.line == r_loc.line && r_loc.col.to_usize() <= MAX_WIDTH {
316             return self.snippet(span);
317         }
318
319         // TODO if lo.col > IDEAL - 10, start a new line (need cur indent for that)
320
321         let s = s.escape_default();
322
323         let offset = offset + 1;
324         let indent = make_indent(offset);
325         let indent = &indent;
326
327         let max_chars = width - 1;
328
329         let mut cur_start = 0;
330         let mut result = String::new();
331         result.push('"');
332         loop {
333             let mut cur_end = cur_start + max_chars;
334
335             if cur_end >= s.len() {
336                 result.push_str(&s[cur_start..]);
337                 break;
338             }
339
340             // Make sure we're on a char boundary.
341             cur_end = next_char(&s, cur_end);
342
343             // Push cur_end left until we reach whitespace
344             while !s.char_at(cur_end-1).is_whitespace() {
345                 cur_end = prev_char(&s, cur_end);
346
347                 if cur_end - cur_start < MIN_STRING {
348                     // We can't break at whitespace, fall back to splitting
349                     // anywhere that doesn't break an escape sequence
350                     cur_end = next_char(&s, cur_start + max_chars);
351                     while s.char_at(cur_end) == '\\' {
352                         cur_end = prev_char(&s, cur_end);
353                     }
354                 }
355             }
356             // Make sure there is no whitespace to the right of the break.
357             while cur_end < s.len() && s.char_at(cur_end).is_whitespace() {
358                 cur_end = next_char(&s, cur_end+1);
359             }
360             result.push_str(&s[cur_start..cur_end]);
361             result.push_str("\\\n");
362             result.push_str(indent);
363
364             cur_start = cur_end;
365         }
366         result.push('"');
367
368         result
369     }
370
371     // Basically just pretty prints a multi-item import.
372     fn rewrite_use_list(&mut self,
373                         path: &ast::Path,
374                         path_list: &[ast::PathListItem],
375                         vp_span: Span) -> String {
376         // FIXME remove unused imports
377
378         // FIXME check indentation
379         let l_loc = self.codemap.lookup_char_pos(vp_span.lo);
380
381         let path_str = pprust::path_to_string(&path);
382
383         // 3 = :: + {
384         let indent = l_loc.col.0 + path_str.len() + 3;
385         let fmt = ListFormatting {
386             tactic: ListTactic::Mixed,
387             separator: ",",
388             trailing_separator: SeparatorTactic::Never,
389             indent: indent,
390             // 2 = } + ;
391             h_width: IDEAL_WIDTH - (indent + path_str.len() + 2),
392             v_width: IDEAL_WIDTH - (indent + path_str.len() + 2),
393         };
394
395         // TODO handle any comments inbetween items.
396         // If `self` is in the list, put it first.
397         let head = if path_list.iter().any(|vpi|
398             if let ast::PathListItem_::PathListMod{ .. } = vpi.node {
399                 true
400             } else {
401                 false
402             }
403         ) {
404             Some(("self".to_string(), String::new()))
405         } else {
406             None
407         };
408
409         let items: Vec<_> = head.into_iter().chain(path_list.iter().filter_map(|vpi| {
410             match vpi.node {
411                 ast::PathListItem_::PathListIdent{ name, .. } => {
412                     Some((token::get_ident(name).to_string(), String::new()))
413                 }
414                 // Skip `self`, because we added it above.
415                 ast::PathListItem_::PathListMod{ .. } => None,
416             }
417         })).collect();
418
419         format!("use {}::{{{}}};", path_str, write_list(&items, &fmt))
420     }
421
422
423     fn rewrite_pred(&self, predicate: &ast::WherePredicate) -> String
424     {
425         // TODO dead spans
426         // TODO assumes we'll always fit on one line...
427         match predicate {
428             &ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bound_lifetimes,
429                                                                           ref bounded_ty,
430                                                                           ref bounds,
431                                                                           ..}) => {
432                 if bound_lifetimes.len() > 0 {
433                     format!("for<{}> {}: {}",
434                             bound_lifetimes.iter().map(|l| self.rewrite_lifetime_def(l)).collect::<Vec<_>>().connect(", "),
435                             pprust::ty_to_string(bounded_ty),
436                             bounds.iter().map(|b| self.rewrite_ty_bound(b)).collect::<Vec<_>>().connect("+"))
437
438                 } else {
439                     format!("{}: {}",
440                             pprust::ty_to_string(bounded_ty),
441                             bounds.iter().map(|b| self.rewrite_ty_bound(b)).collect::<Vec<_>>().connect("+"))
442                 }
443             }
444             &ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
445                                                                             ref bounds,
446                                                                             ..}) => {
447                 format!("{}: {}",
448                         pprust::lifetime_to_string(lifetime),
449                         bounds.iter().map(|l| pprust::lifetime_to_string(l)).collect::<Vec<_>>().connect("+"))
450             }
451             &ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref path, ref ty, ..}) => {
452                 format!("{} = {}", pprust::path_to_string(path), pprust::ty_to_string(ty))
453             }
454         }
455     }
456
457     fn rewrite_lifetime_def(&self, lifetime: &ast::LifetimeDef) -> String
458     {
459         if lifetime.bounds.len() == 0 {
460             return pprust::lifetime_to_string(&lifetime.lifetime);
461         }
462
463         format!("{}: {}",
464                 pprust::lifetime_to_string(&lifetime.lifetime),
465                 lifetime.bounds.iter().map(|l| pprust::lifetime_to_string(l)).collect::<Vec<_>>().connect("+"))
466     }
467
468     fn rewrite_ty_bound(&self, bound: &ast::TyParamBound) -> String
469     {
470         match *bound {
471             ast::TyParamBound::TraitTyParamBound(ref tref, ast::TraitBoundModifier::None) => {
472                 self.rewrite_poly_trait_ref(tref)
473             }
474             ast::TyParamBound::TraitTyParamBound(ref tref, ast::TraitBoundModifier::Maybe) => {
475                 format!("?{}", self.rewrite_poly_trait_ref(tref))
476             }
477             ast::TyParamBound::RegionTyParamBound(ref l) => {
478                 pprust::lifetime_to_string(l)
479             }
480         }
481     }
482
483     fn rewrite_ty_param(&self, ty_param: &ast::TyParam) -> String
484     {
485         let mut result = String::with_capacity(128);
486         result.push_str(&token::get_ident(ty_param.ident));
487         if ty_param.bounds.len() > 0 {
488             result.push_str(": ");
489             result.push_str(&ty_param.bounds.iter().map(|b| self.rewrite_ty_bound(b)).collect::<Vec<_>>().connect(", "));
490         }
491         if let Some(ref def) = ty_param.default {
492             result.push_str(" = ");
493             result.push_str(&pprust::ty_to_string(&def));
494         }
495
496         result
497     }
498
499     fn rewrite_poly_trait_ref(&self, t: &ast::PolyTraitRef) -> String
500     {
501         if t.bound_lifetimes.len() > 0 {
502             format!("for<{}> {}",
503                     t.bound_lifetimes.iter().map(|l| self.rewrite_lifetime_def(l)).collect::<Vec<_>>().connect(", "),
504                     pprust::path_to_string(&t.trait_ref.path))
505
506         } else {
507             pprust::path_to_string(&t.trait_ref.path)
508         }
509     }
510
511     fn rewrite_call(&mut self,
512                     callee: &ast::Expr,
513                     args: &[ptr::P<ast::Expr>],
514                     width: usize,
515                     offset: usize)
516         -> String
517     {
518         debug!("rewrite_call, width: {}, offset: {}", width, offset);
519
520         // TODO using byte lens instead of char lens (and probably all over the place too)
521         let callee_str = self.rewrite_expr(callee, width, offset);
522         debug!("rewrite_call, callee_str: `{}`", callee_str);
523         // 2 is for parens.
524         let remaining_width = width - callee_str.len() - 2;
525         let offset = callee_str.len() + 1 + offset;
526         let arg_count = args.len();
527
528         let args_str = if arg_count > 0 {
529             let args: Vec<_> = args.iter().map(|e| (self.rewrite_expr(e,
530                                                                       remaining_width,
531                                                                       offset), String::new())).collect();
532             // TODO move this into write_list
533             let tactics = if args.iter().any(|&(ref s, _)| s.contains('\n')) {
534                 ListTactic::Vertical
535             } else {
536                 ListTactic::HorizontalVertical
537             };
538             let fmt = ListFormatting {
539                 tactic: tactics,
540                 separator: ",",
541                 trailing_separator: SeparatorTactic::Never,
542                 indent: offset,
543                 h_width: remaining_width,
544                 v_width: remaining_width,
545             };
546             write_list(&args, &fmt)
547         } else {
548             String::new()
549         };
550
551         format!("{}({})", callee_str, args_str)
552     }
553
554     fn rewrite_expr(&mut self, expr: &ast::Expr, width: usize, offset: usize) -> String {
555         match expr.node {
556             ast::Expr_::ExprLit(ref l) => {
557                 match l.node {
558                     ast::Lit_::LitStr(ref is, _) => {
559                         return self.rewrite_string_lit(&is, l.span, width, offset);
560                     }
561                     _ => {}
562                 }
563             }
564             ast::Expr_::ExprCall(ref callee, ref args) => {
565                 return self.rewrite_call(callee, args, width, offset);
566             }
567             _ => {}
568         }
569
570         let result = self.snippet(expr.span);
571         debug!("snippet: {}", result);
572         result
573     }
574 }
575
576 #[inline]
577 fn prev_char(s: &str, mut i: usize) -> usize {
578     if i == 0 { return 0; }
579
580     i -= 1;
581     while !s.is_char_boundary(i) {
582         i -= 1;
583     }
584     i
585 }
586
587 #[inline]
588 fn next_char(s: &str, mut i: usize) -> usize {
589     if i >= s.len() { return s.len(); }
590
591     while !s.is_char_boundary(i) {
592         i += 1;
593     }
594     i
595 }
596
597 #[inline]
598 fn make_indent(width: usize) -> String {
599     let mut indent = String::with_capacity(width);
600     for _ in 0..width {
601         indent.push(' ')
602     }
603     indent
604 }
605
606 struct RustFmtCalls {
607     input_path: Option<PathBuf>,
608 }
609
610 impl<'a> CompilerCalls<'a> for RustFmtCalls {
611     fn early_callback(&mut self,
612                       _: &getopts::Matches,
613                       _: &diagnostics::registry::Registry)
614                       -> Compilation {
615         Compilation::Continue
616     }
617
618     fn some_input(&mut self,
619                   input: Input,
620                   input_path: Option<PathBuf>)
621                   -> (Input, Option<PathBuf>) {
622         match input_path {
623             Some(ref ip) => self.input_path = Some(ip.clone()),
624             _ => {
625                 // FIXME should handle string input and write to stdout or something
626                 panic!("No input path");
627             }
628         }
629         (input, input_path)
630     }
631
632     fn no_input(&mut self,
633                 _: &getopts::Matches,
634                 _: &config::Options,
635                 _: &Option<PathBuf>,
636                 _: &Option<PathBuf>,
637                 _: &diagnostics::registry::Registry)
638                 -> Option<(Input, Option<PathBuf>)> {
639         panic!("No input supplied to RustFmt");
640     }
641
642     fn late_callback(&mut self,
643                      _: &getopts::Matches,
644                      _: &Session,
645                      _: &Input,
646                      _: &Option<PathBuf>,
647                      _: &Option<PathBuf>)
648                      -> Compilation {
649         Compilation::Continue
650     }
651
652     fn build_controller(&mut self, _: &Session) -> driver::CompileController<'a> {
653         let mut control = driver::CompileController::basic();
654         control.after_parse.stop = Compilation::Stop;
655         control.after_parse.callback = box |state| {
656             let krate = state.krate.unwrap();
657             let codemap = state.session.codemap();
658             let mut changes = fmt_ast(krate, codemap);
659             fmt_lines(&mut changes);
660
661             // FIXME(#5) Should be user specified whether to show or replace.
662             let result = changes.write_all_files(WriteMode::Display);
663
664             if let Err(msg) = result {
665                 println!("Error writing files: {}", msg);
666             }
667         };
668
669         control
670     }
671 }
672
673 fn main() {
674     let args: Vec<_> = std::env::args().collect();
675     let mut call_ctxt = RustFmtCalls { input_path: None };
676     rustc_driver::run_compiler(&args, &mut call_ctxt);
677     std::env::set_exit_status(0);
678
679     // TODO unit tests
680     // let fmt = ListFormatting {
681     //     tactic: ListTactic::Horizontal,
682     //     separator: ",",
683     //     trailing_separator: SeparatorTactic::Vertical,
684     //     indent: 2,
685     //     h_width: 80,
686     //     v_width: 100,
687     // };
688     // let inputs = vec![(format!("foo"), String::new()),
689     //                   (format!("foo"), String::new()),
690     //                   (format!("foo"), String::new()),
691     //                   (format!("foo"), String::new()),
692     //                   (format!("foo"), String::new()),
693     //                   (format!("foo"), String::new()),
694     //                   (format!("foo"), String::new()),
695     //                   (format!("foo"), String::new())];
696     // let s = write_list(&inputs, &fmt);
697     // println!("  {}", s);
698 }
699
700 // FIXME comments
701 // comments aren't in the AST, which makes processing them difficult, but then
702 // comments are complicated anyway. I think I am happy putting off tackling them
703 // for now. Long term the soluton is for comments to be in the AST, but that means
704 // only the libsyntax AST, not the rustc one, which means waiting for the ASTs
705 // to diverge one day....
706
707 // Once we do have comments, we just have to implement a simple word wrapping
708 // algorithm to keep the width under IDEAL_WIDTH. We should also convert multiline
709 // /* ... */ comments to // and check doc comments are in the right place and of
710 // the right kind.
711
712 // Should also make sure comments have the right indent