]> git.lizzy.rs Git - rust.git/commitdiff
rustfmt librustc_trans/save
authorNick Cameron <ncameron@mozilla.com>
Wed, 2 Sep 2015 03:37:07 +0000 (15:37 +1200)
committerNick Cameron <ncameron@mozilla.com>
Fri, 4 Sep 2015 21:45:35 +0000 (09:45 +1200)
src/librustc_trans/save/dump_csv.rs
src/librustc_trans/save/mod.rs
src/librustc_trans/save/recorder.rs
src/librustc_trans/save/span_utils.rs

index 9960d022d5300c535086b27743b32827ce8e2cad..581c9bc597fc683f87a271e8ccdbb3d5a0fd45a5 100644 (file)
@@ -71,13 +71,14 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
     span: SpanUtils<'l>,
     fmt: FmtStrs<'l>,
 
-    cur_scope: NodeId
+    cur_scope: NodeId,
 }
 
 impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
     pub fn new(tcx: &'l ty::ctxt<'tcx>,
                analysis: &'l ty::CrateAnalysis,
-               output_file: Box<File>) -> DumpCsvVisitor<'l, 'tcx> {
+               output_file: Box<File>)
+               -> DumpCsvVisitor<'l, 'tcx> {
         let span_utils = SpanUtils::new(&tcx.sess);
         DumpCsvVisitor {
             sess: &tcx.sess,
@@ -85,16 +86,14 @@ pub fn new(tcx: &'l ty::ctxt<'tcx>,
             save_ctxt: SaveContext::from_span_utils(tcx, span_utils.clone()),
             analysis: analysis,
             span: span_utils.clone(),
-            fmt: FmtStrs::new(box Recorder {
-                                out: output_file,
-                                dump_spans: false,
-                              }, span_utils),
-            cur_scope: 0
+            fmt: FmtStrs::new(box Recorder { out: output_file, dump_spans: false },
+                              span_utils),
+            cur_scope: 0,
         }
     }
 
-    fn nest<F>(&mut self, scope_id: NodeId, f: F) where
-        F: FnOnce(&mut DumpCsvVisitor<'l, 'tcx>),
+    fn nest<F>(&mut self, scope_id: NodeId, f: F)
+        where F: FnOnce(&mut DumpCsvVisitor<'l, 'tcx>)
     {
         let parent_scope = self.cur_scope;
         self.cur_scope = scope_id;
@@ -140,9 +139,11 @@ fn process_path_prefixes(&self, path: &ast::Path) -> Vec<(Span, String)> {
         let mut segs = vec!();
         for (i, (seg, span)) in path.segments.iter().zip(&spans).enumerate() {
             segs.push(seg.clone());
-            let sub_path = ast::Path{span: *span, // span for the last segment
-                                     global: path.global,
-                                     segments: segs};
+            let sub_path = ast::Path {
+                span: *span, // span for the last segment
+                global: path.global,
+                segments: segs,
+            };
             let qualname = if i == 0 && path.global {
                 format!("::{}", path_to_string(&sub_path))
             } else {
@@ -271,7 +272,7 @@ fn lookup_def_kind(&self, ref_id: NodeId, span: Span) -> Option<recorder::Row> {
             def::DefPrimTy(_) => {
                 self.sess.span_bug(span, &format!("lookup_def_kind for unexpected item: {:?}",
                                                  def));
-            },
+            }
         }
     }
 
@@ -357,9 +358,7 @@ fn process_trait_ref(&mut self, trait_ref: &ast::TraitRef) {
         }
     }
 
-    fn process_struct_field_def(&mut self,
-                                field: &ast::StructField,
-                                parent_id: NodeId) {
+    fn process_struct_field_def(&mut self, field: &ast::StructField, parent_id: NodeId) {
         let field_data = self.save_ctxt.get_field_data(field, parent_id);
         if let Some(field_data) = field_data {
             self.fmt.field_str(field.span,
@@ -374,7 +373,7 @@ fn process_struct_field_def(&mut self,
 
     // Dump generic params bindings, then visit_generics
     fn process_generic_params(&mut self,
-                              generics:&ast::Generics,
+                              generics: &ast::Generics,
                               full_span: Span,
                               prefix: &str,
                               id: NodeId) {
@@ -427,11 +426,7 @@ fn process_fn(&mut self,
         self.nest(item.id, |v| v.visit_block(&body));
     }
 
-    fn process_static_or_const_item(&mut self,
-                                    item: &ast::Item,
-                                    typ: &ast::Ty,
-                                    expr: &ast::Expr)
-    {
+    fn process_static_or_const_item(&mut self, item: &ast::Item, typ: &ast::Ty, expr: &ast::Expr) {
         let var_data = self.save_ctxt.get_item_data(item);
         down_cast_data!(var_data, VariableData, self, item.span);
         self.fmt.static_str(item.span,
@@ -452,8 +447,7 @@ fn process_const(&mut self,
                      ident: &ast::Ident,
                      span: Span,
                      typ: &ast::Ty,
-                     expr: &ast::Expr)
-    {
+                     expr: &ast::Expr) {
         let qualname = format!("::{}", self.tcx.map.path_to_string(id));
 
         let sub_span = self.span.sub_span_after_keyword(span,
@@ -641,8 +635,8 @@ fn process_trait(&mut self,
                                          sub_span,
                                          id,
                                          item.id);
-                },
-                None => ()
+                }
+                None => (),
             }
         }
 
@@ -653,8 +647,7 @@ fn process_trait(&mut self,
         }
     }
 
-    fn process_mod(&mut self,
-                   item: &ast::Item) {  // The module in question, represented as an item.
+    fn process_mod(&mut self, item: &ast::Item) {  // The module in question, represented as an item.
         let mod_data = self.save_ctxt.get_item_data(item);
         down_cast_data!(mod_data, ModData, self, item.span);
         self.fmt.mod_str(item.span,
@@ -665,10 +658,7 @@ fn process_mod(&mut self,
                          &mod_data.filename);
     }
 
-    fn process_path(&mut self,
-                    id: NodeId,
-                    path: &ast::Path,
-                    ref_kind: Option<recorder::Row>) {
+    fn process_path(&mut self, id: NodeId, path: &ast::Path, ref_kind: Option<recorder::Row>) {
         if generated_code(path.span) {
             return;
         }
@@ -737,7 +727,7 @@ fn process_path(&mut self,
             def::DefStruct(_) |
             def::DefVariant(..) |
             def::DefFn(..) => self.write_sub_paths_truncated(path, false),
-            _ => {},
+            _ => {}
         }
     }
 
@@ -783,9 +773,7 @@ fn process_struct_lit(&mut self,
         visit::walk_expr_opt(self, base)
     }
 
-    fn process_method_call(&mut self,
-                           ex: &ast::Expr,
-                           args: &Vec<P<ast::Expr>>) {
+    fn process_method_call(&mut self, ex: &ast::Expr, args: &Vec<P<ast::Expr>>) {
         if let Some(call_data) = self.save_ctxt.get_expr_data(ex) {
             down_cast_data!(call_data, MethodCallData, self, ex.span);
             self.fmt.meth_call_str(ex.span,
@@ -799,7 +787,7 @@ fn process_method_call(&mut self,
         visit::walk_exprs(self, &args);
     }
 
-    fn process_pat(&mut self, p:&ast::Pat) {
+    fn process_pat(&mut self, p: &ast::Pat) {
         if generated_code(p.span) {
             return;
         }
@@ -827,7 +815,7 @@ fn process_pat(&mut self, p:&ast::Pat) {
                     self.visit_pat(&field.pat);
                 }
             }
-            _ => visit::walk_pat(self, p)
+            _ => visit::walk_pat(self, p),
         }
     }
 }
@@ -851,10 +839,10 @@ fn visit_item(&mut self, item: &ast::Item) {
                                                                    sub_span,
                                                                    def_id,
                                                                    self.cur_scope),
-                                    None => {},
+                                    None => {}
                                 }
                                 Some(def_id)
-                            },
+                            }
                             None => None,
                         };
 
@@ -902,20 +890,19 @@ fn visit_item(&mut self, item: &ast::Item) {
                             match plid.node {
                                 ast::PathListIdent { id, .. } => {
                                     match self.lookup_type_ref(id) {
-                                        Some(def_id) =>
-                                            match self.lookup_def_kind(id, plid.span) {
-                                                Some(kind) => {
-                                                    self.fmt.ref_str(
+                                        Some(def_id) => match self.lookup_def_kind(id, plid.span) {
+                                            Some(kind) => {
+                                                self.fmt.ref_str(
                                                         kind, plid.span,
                                                         Some(plid.span),
                                                         def_id, self.cur_scope);
-                                                }
-                                                None => ()
-                                            },
-                                        None => ()
+                                            }
+                                            None => (),
+                                        },
+                                        None => (),
                                     }
-                                },
-                                ast::PathListMod { .. } => ()
+                                }
+                                ast::PathListMod { .. } => (),
                             }
                         }
 
@@ -978,7 +965,7 @@ fn visit_item(&mut self, item: &ast::Item) {
 
                 self.visit_ty(&**ty);
                 self.process_generic_params(ty_params, item.span, &qualname, item.id);
-            },
+            }
             ast::ItemMac(_) => (),
             _ => visit::walk_item(self, item),
         }
@@ -1048,14 +1035,14 @@ fn visit_ty(&mut self, t: &ast::Ty) {
                                          sub_span,
                                          id,
                                          self.cur_scope);
-                    },
-                    None => ()
+                    }
+                    None => (),
                 }
 
                 self.write_sub_paths_truncated(path, false);
 
                 visit::walk_path(self, path);
-            },
+            }
             _ => visit::walk_ty(self, t),
         }
     }
@@ -1101,7 +1088,7 @@ fn visit_expr(&mut self, ex: &ast::Expr) {
                                      field_data.ref_id,
                                      field_data.scope);
                 }
-            },
+            }
             ast::ExprTupField(ref sub_ex, idx) => {
                 if generated_code(sub_ex.span) {
                     return
@@ -1125,7 +1112,7 @@ fn visit_expr(&mut self, ex: &ast::Expr) {
                                             &format!("Expected struct or tuple \
                                                       type, found {:?}", ty)),
                 }
-            },
+            }
             ast::ExprClosure(_, ref decl, ref body) => {
                 if generated_code(body.span) {
                     return
@@ -1146,7 +1133,7 @@ fn visit_expr(&mut self, ex: &ast::Expr) {
 
                 // walk the body
                 self.nest(ex.id, |v| v.visit_block(&**body));
-            },
+            }
             _ => {
                 visit::walk_expr(self, ex)
             }
@@ -1182,7 +1169,7 @@ fn visit_arm(&mut self, arm: &ast::Arm) {
             }
             let def = def_map.get(&id).unwrap().full_def();
             match def {
-                def::DefLocal(id)  => {
+                def::DefLocal(id) => {
                     let value = if immut == ast::MutImmutable {
                         self.span.snippet(p.span).to_string()
                     } else {
@@ -1205,7 +1192,7 @@ fn visit_arm(&mut self, arm: &ast::Arm) {
                 def::DefConst(..) |
                 def::DefAssociatedConst(..) => {}
                 _ => error!("unexpected definition kind when processing collected paths: {:?}",
-                            def)
+                            def),
             }
         }
 
index 42a7ea0a6935328162d2bc1991c8c7a241a6cdba..9c6f1a0eb5a89bd6794b558bfea4c570af0d14a5 100644 (file)
@@ -176,7 +176,7 @@ pub struct MethodCallData {
 
 
 impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
-    pub fn new(tcx: &'l ty::ctxt<'tcx>) -> SaveContext <'l, 'tcx> {
+    pub fn new(tcx: &'l ty::ctxt<'tcx>) -> SaveContext<'l, 'tcx> {
         let span_utils = SpanUtils::new(&tcx.sess);
         SaveContext::from_span_utils(tcx, span_utils)
     }
@@ -184,10 +184,7 @@ pub fn new(tcx: &'l ty::ctxt<'tcx>) -> SaveContext <'l, 'tcx> {
     pub fn from_span_utils(tcx: &'l ty::ctxt<'tcx>,
                            span_utils: SpanUtils<'l>)
                            -> SaveContext<'l, 'tcx> {
-        SaveContext {
-            tcx: tcx,
-            span_utils: span_utils,
-        }
+        SaveContext { tcx: tcx, span_utils: span_utils }
     }
 
     // List external crates used by the current crate.
@@ -268,7 +265,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Data {
                     scope: self.enclosing_scope(item.id),
                     filename: filename,
                 })
-            },
+            }
             ast::ItemEnum(..) => {
                 let enum_name = format!("::{}", self.tcx.map.path_to_string(item.id));
                 let val = self.span_utils.snippet(item.span);
@@ -281,7 +278,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Data {
                     qualname: enum_name,
                     scope: self.enclosing_scope(item.id),
                 })
-            },
+            }
             ast::ItemImpl(_, _, _, ref trait_ref, ref typ, _) => {
                 let mut type_data = None;
                 let sub_span;
@@ -297,7 +294,7 @@ pub fn get_item_data(&self, item: &ast::Item) -> Data {
                             scope: parent,
                             ref_id: id,
                         });
-                    },
+                    }
                     _ => {
                         // Less useful case, impl for a compound type.
                         let span = typ.span;
@@ -341,17 +338,14 @@ pub fn get_field_data(&self, field: &ast::StructField, scope: NodeId) -> Option<
                     value: "".to_owned(),
                     type_value: typ,
                 })
-            },
+            }
             _ => None,
         }
     }
 
     // FIXME would be nice to take a MethodItem here, but the ast provides both
     // trait and impl flavours, so the caller must do the disassembly.
-    pub fn get_method_data(&self,
-                           id: ast::NodeId,
-                           name: ast::Name,
-                           span: Span) -> FunctionData {
+    pub fn get_method_data(&self, id: ast::NodeId, name: ast::Name, span: Span) -> FunctionData {
         // The qualname for a method is the trait name or name of the struct in an impl in
         // which the method is declared in, followed by the method's name.
         let qualname = match self.tcx.impl_of_method(DefId::local(id)) {
@@ -367,7 +361,7 @@ pub fn get_method_data(&self,
                                     result.push_str(" as ");
                                     result.push_str(
                                         &self.tcx.item_path_str(def_id));
-                                },
+                                }
                                 None => {}
                             }
                             result.push_str(">");
@@ -377,14 +371,14 @@ pub fn get_method_data(&self,
                             self.tcx.sess.span_bug(span,
                                 &format!("Container {} for method {} not an impl?",
                                          impl_id.node, id));
-                        },
+                        }
                     }
-                },
+                }
                 _ => {
                     self.tcx.sess.span_bug(span,
                         &format!("Container {} for method {} is not a node item {:?}",
                                  impl_id.node, id, self.tcx.map.get(impl_id.node)));
-                },
+                }
             },
             None => match self.tcx.trait_of_item(DefId::local(id)) {
                 Some(def_id) => {
@@ -398,11 +392,11 @@ pub fn get_method_data(&self,
                                          def_id.node, id));
                         }
                     }
-                },
+                }
                 None => {
                     self.tcx.sess.span_bug(span,
                         &format!("Could not find container for method {}", id));
-                },
+                }
             },
         };
 
@@ -492,7 +486,7 @@ pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
                 let method_id = self.tcx.tables.borrow().method_map[&method_call].def_id;
                 let (def_id, decl_id) = match self.tcx.impl_or_trait_item(method_id).container() {
                     ty::ImplContainer(_) => (Some(method_id), None),
-                    ty::TraitContainer(_) => (None, Some(method_id))
+                    ty::TraitContainer(_) => (None, Some(method_id)),
                 };
                 let sub_span = self.span_utils.sub_span_for_meth_name(expr.span);
                 let parent = self.enclosing_scope(expr.id);
@@ -513,10 +507,7 @@ pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
         }
     }
 
-    pub fn get_path_data(&self,
-                         id: NodeId,
-                         path: &ast::Path)
-                         -> Option<Data> {
+    pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Data> {
         let def_map = self.tcx.def_map.borrow();
         if !def_map.contains_key(&id) {
             self.tcx.sess.span_bug(path.span,
@@ -583,7 +574,7 @@ pub fn get_path_data(&self,
                     ref_id: def_id,
                     decl_id: Some(decl_id),
                 }))
-            },
+            }
             def::DefFn(def_id, _) => {
                 Some(Data::FunctionCallData(FunctionCallData {
                     ref_id: def_id,
@@ -663,9 +654,7 @@ struct PathCollector {
 
 impl PathCollector {
     fn new() -> PathCollector {
-        PathCollector {
-            collected_paths: vec![],
-        }
+        PathCollector { collected_paths: vec![] }
     }
 }
 
@@ -722,7 +711,7 @@ pub fn process_crate(tcx: &ty::ctxt,
         None => {
             info!("Could not find crate name, using 'unknown_crate'");
             String::from("unknown_crate")
-        },
+        }
     };
 
     info!("Dumping crate {}", cratename);
@@ -775,5 +764,5 @@ fn escape(s: String) -> String {
 // If the expression is a macro expansion or other generated code, run screaming
 // and don't index.
 pub fn generated_code(span: Span) -> bool {
-    span.expn_id != NO_EXPANSION || span  == DUMMY_SP
+    span.expn_id != NO_EXPANSION || span == DUMMY_SP
 }
index f9c3bf0694b1ec64fd48ebf7b06269c1fa0be62c..f8e6864985364a8d72614de61e149859ac8fc5be 100644 (file)
 use std::io::Write;
 
 use syntax::ast;
-use syntax::ast::{NodeId};
+use syntax::ast::NodeId;
 use syntax::codemap::*;
 
 const ZERO_DEF_ID: DefId = DefId { node: 0, krate: 0 };
 
 pub struct Recorder {
     // output file
-    pub out: Box<Write+'static>,
+    pub out: Box<Write + 'static>,
     pub dump_spans: bool,
 }
 
@@ -37,11 +37,7 @@ pub fn record(&mut self, info: &str) {
         }
     }
 
-    pub fn dump_span(&mut self,
-                     su: SpanUtils,
-                     kind: &str,
-                     span: Span,
-                     _sub_span: Option<Span>) {
+    pub fn dump_span(&mut self, su: SpanUtils, kind: &str, span: Span, _sub_span: Option<Span>) {
         assert!(self.dump_spans);
         let result = format!("span,kind,{},{},text,\"{}\"\n",
                              kind, su.extent_str(span), escape(su.snippet(span)));
@@ -96,10 +92,7 @@ pub enum Row {
 
 impl<'a> FmtStrs<'a> {
     pub fn new(rec: Box<Recorder>, span: SpanUtils<'a>) -> FmtStrs<'a> {
-        FmtStrs {
-            recorder: rec,
-            span: span,
-        }
+        FmtStrs { recorder: rec, span: span }
     }
 
     // A map from kind of item to a tuple of
@@ -111,47 +104,51 @@ fn lookup_row(r: Row) -> (&'static str, Vec<&'static str>, bool, bool) {
         match r {
             Variable => ("variable",
                          vec!("id","name","qualname","value","type","scopeid"),
-                         true, true),
+                         true,
+                         true),
             Enum => ("enum", vec!("id","qualname","scopeid","value"), true, true),
             Variant => ("variant",
                         vec!("id","name","qualname","type","value","scopeid"),
-                        true, true),
+                        true,
+                        true),
             VariantStruct => ("variant_struct",
                               vec!("id","ctor_id","qualname","type","value","scopeid"),
-                              true, true),
+                              true,
+                              true),
             Function => ("function",
                          vec!("id","qualname","declid","declidcrate","scopeid"),
-                         true, true),
+                         true,
+                         true),
             MethodDecl => ("method_decl", vec!("id","qualname","scopeid"), true, true),
             Struct => ("struct", vec!("id","ctor_id","qualname","scopeid","value"), true, true),
             Trait => ("trait", vec!("id","qualname","scopeid","value"), true, true),
             Impl => ("impl",
                      vec!("id","refid","refidcrate","traitid","traitidcrate","scopeid"),
-                     true, true),
+                     true,
+                     true),
             Module => ("module", vec!("id","qualname","scopeid","def_file"), true, false),
-            UseAlias => ("use_alias",
-                         vec!("id","refid","refidcrate","name","scopeid"),
-                         true, true),
+            UseAlias => ("use_alias", vec!("id","refid","refidcrate","name","scopeid"), true, true),
             UseGlob => ("use_glob", vec!("id","value","scopeid"), true, true),
             ExternCrate => ("extern_crate",
                             vec!("id","name","location","crate","scopeid"),
-                            true, true),
+                            true,
+                            true),
             Inheritance => ("inheritance",
                             vec!("base","basecrate","derived","derivedcrate"),
-                            true, false),
+                            true,
+                            false),
             MethodCall => ("method_call",
                            vec!("refid","refidcrate","declid","declidcrate","scopeid"),
-                           true, true),
+                           true,
+                           true),
             Typedef => ("typedef", vec!("id","qualname","value"), true, true),
             ExternalCrate => ("external_crate", vec!("name","crate","file_name"), false, false),
             Crate => ("crate", vec!("name"), true, false),
             FnCall => ("fn_call", vec!("refid","refidcrate","qualname","scopeid"), true, true),
             ModRef => ("mod_ref", vec!("refid","refidcrate","qualname","scopeid"), true, true),
             VarRef => ("var_ref", vec!("refid","refidcrate","qualname","scopeid"), true, true),
-            TypeRef => ("type_ref",
-                        vec!("refid","refidcrate","qualname","scopeid"),
-                        true, true),
-            FnRef => ("fn_ref", vec!("refid","refidcrate","qualname","scopeid"), true, true)
+            TypeRef => ("type_ref", vec!("refid","refidcrate","qualname","scopeid"), true, true),
+            FnRef => ("fn_ref", vec!("refid","refidcrate","qualname","scopeid"), true, true),
         }
     }
 
@@ -159,7 +156,8 @@ pub fn make_values_str(&self,
                            kind: &'static str,
                            fields: &Vec<&'static str>,
                            values: Vec<String>,
-                           span: Span) -> Option<String> {
+                           span: Span)
+                           -> Option<String> {
         if values.len() != fields.len() {
             self.span.sess.span_bug(span, &format!(
                 "Mismatch between length of fields for '{}', expected '{}', found '{}'",
@@ -183,10 +181,7 @@ pub fn make_values_str(&self,
         }))
     }
 
-    pub fn record_without_span(&mut self,
-                               kind: Row,
-                               values: Vec<String>,
-                               span: Span) {
+    pub fn record_without_span(&mut self, kind: Row, values: Vec<String>, span: Span) {
         let (label, ref fields, needs_span, dump_spans) = FmtStrs::lookup_row(kind);
 
         if needs_span {
@@ -387,7 +382,7 @@ pub fn method_str(&mut self,
                       scope_id: NodeId) {
         let values = match decl_id {
             Some(decl_id) => svec!(id, name, decl_id.node, decl_id.krate, scope_id),
-            None => svec!(id, name, "", "", scope_id)
+            None => svec!(id, name, "", "", scope_id),
         };
         self.check_and_record(Function,
                               span,
@@ -476,7 +471,7 @@ pub fn use_alias_str(&mut self,
                          parent: NodeId) {
         let (mod_node, mod_crate) = match mod_id {
             Some(mod_id) => (mod_id.node, mod_id.krate),
-            None => (0, 0)
+            None => (0, 0),
         };
         self.check_and_record(UseAlias,
                               span,
@@ -528,7 +523,7 @@ pub fn fn_call_str(&mut self,
                        span: Span,
                        sub_span: Option<Span>,
                        id: DefId,
-                       scope_id:NodeId) {
+                       scope_id: NodeId) {
         self.check_and_record(FnCall,
                               span,
                               sub_span,
@@ -543,11 +538,11 @@ pub fn meth_call_str(&mut self,
                          scope_id: NodeId) {
         let (dfn, dfk) = match defid {
             Some(defid) => (defid.node, defid.krate),
-            None => (0, 0)
+            None => (0, 0),
         };
         let (dcn, dck) = match declid {
             Some(declid) => (s!(declid.node), s!(declid.krate)),
-            None => ("".to_string(), "".to_string())
+            None => ("".to_string(), "".to_string()),
         };
         self.check_and_record(MethodCall,
                               span,
@@ -555,11 +550,7 @@ pub fn meth_call_str(&mut self,
                               svec!(dfn, dfk, dcn, dck, scope_id));
     }
 
-    pub fn sub_mod_ref_str(&mut self,
-                           span: Span,
-                           sub_span: Span,
-                           qualname: &str,
-                           parent:NodeId) {
+    pub fn sub_mod_ref_str(&mut self, span: Span, sub_span: Span, qualname: &str, parent: NodeId) {
         self.record_with_span(ModRef,
                               span,
                               sub_span,
@@ -578,29 +569,21 @@ pub fn typedef_str(&mut self,
                               svec!(id, qualname, value));
     }
 
-    pub fn crate_str(&mut self,
-                     span: Span,
-                     name: &str) {
+    pub fn crate_str(&mut self, span: Span, name: &str) {
         self.record_with_span(Crate,
                               span,
                               span,
                               svec!(name));
     }
 
-    pub fn external_crate_str(&mut self,
-                              span: Span,
-                              name: &str,
-                              num: ast::CrateNum) {
+    pub fn external_crate_str(&mut self, span: Span, name: &str, num: ast::CrateNum) {
         let lo_loc = self.span.sess.codemap().lookup_char_pos(span.lo);
         self.record_without_span(ExternalCrate,
                                  svec!(name, num, lo_loc.file.name),
                                  span);
     }
 
-    pub fn sub_type_ref_str(&mut self,
-                            span: Span,
-                            sub_span: Span,
-                            qualname: &str) {
+    pub fn sub_type_ref_str(&mut self, span: Span, sub_span: Span, qualname: &str) {
         self.record_with_span(TypeRef,
                               span,
                               sub_span,
index ee7b1c4ff6e29a5d12a71c28619a8ffa231908a7..5647e88658a3b9cb934a397f1054313c8b089128 100644 (file)
@@ -17,7 +17,7 @@
 use syntax::ast;
 use syntax::codemap::*;
 use syntax::parse::lexer;
-use syntax::parse::lexer::{Reader,StringReader};
+use syntax::parse::lexer::{Reader, StringReader};
 use syntax::parse::token;
 use syntax::parse::token::{keywords, Token};
 
@@ -29,10 +29,7 @@ pub struct SpanUtils<'a> {
 
 impl<'a> SpanUtils<'a> {
     pub fn new(sess: &'a Session) -> SpanUtils<'a> {
-        SpanUtils {
-            sess: sess,
-            err_count: Cell::new(0)
-        }
+        SpanUtils { sess: sess, err_count: Cell::new(0) }
     }
 
     // Standard string for extents/location.
@@ -62,8 +59,7 @@ pub fn make_sub_span(&self, span: Span, sub_span: Option<Span>) -> Option<Span>
         match sub_span {
             None => None,
             Some(sub) => {
-                let FileMapAndBytePos {fm, pos} =
-                    self.sess.codemap().lookup_byte_offset(span.lo);
+                let FileMapAndBytePos {fm, pos} = self.sess.codemap().lookup_byte_offset(span.lo);
                 let base = pos + fm.start_pos;
                 Some(Span {
                     lo: base + self.sess.codemap().lookup_byte_offset(sub.lo).pos,
@@ -107,8 +103,7 @@ pub fn span_for_last_ident(&self, span: Span) -> Option<Span> {
             if ts.tok == token::Eof {
                 return self.make_sub_span(span, result)
             }
-            if bracket_count == 0 &&
-               (ts.tok.is_ident() || ts.tok.is_keyword(keywords::SelfValue)) {
+            if bracket_count == 0 && (ts.tok.is_ident() || ts.tok.is_keyword(keywords::SelfValue)) {
                 result = Some(ts.sp);
             }
 
@@ -116,7 +111,7 @@ pub fn span_for_last_ident(&self, span: Span) -> Option<Span> {
                 token::Lt => 1,
                 token::Gt => -1,
                 token::BinOp(token::Shr) => -2,
-                _ => 0
+                _ => 0,
             }
         }
     }
@@ -130,8 +125,7 @@ pub fn span_for_first_ident(&self, span: Span) -> Option<Span> {
             if ts.tok == token::Eof {
                 return None;
             }
-            if bracket_count == 0 &&
-               (ts.tok.is_ident() || ts.tok.is_keyword(keywords::SelfValue)) {
+            if bracket_count == 0 && (ts.tok.is_ident() || ts.tok.is_keyword(keywords::SelfValue)) {
                 return self.make_sub_span(span, Some(ts.sp));
             }
 
@@ -139,7 +133,7 @@ pub fn span_for_first_ident(&self, span: Span) -> Option<Span> {
                 token::Lt => 1,
                 token::Gt => -1,
                 token::BinOp(token::Shr) => -2,
-                _ => 0
+                _ => 0,
             }
         }
     }
@@ -156,20 +150,16 @@ pub fn sub_span_for_meth_name(&self, span: Span) -> Option<Span> {
             last_span = None;
             let mut next = toks.real_token();
 
-            if (next.tok == token::OpenDelim(token::Paren) ||
-                next.tok == token::Lt) &&
-               bracket_count == 0 &&
-               prev.tok.is_ident() {
+            if (next.tok == token::OpenDelim(token::Paren) || next.tok == token::Lt) &&
+               bracket_count == 0 && prev.tok.is_ident() {
                 result = Some(prev.sp);
             }
 
-            if bracket_count == 0 &&
-                next.tok == token::ModSep {
+            if bracket_count == 0 && next.tok == token::ModSep {
                 let old = prev;
                 prev = next;
                 next = toks.real_token();
-                if next.tok == token::Lt &&
-                   old.tok.is_ident() {
+                if next.tok == token::Lt && old.tok.is_ident() {
                     result = Some(old.sp);
                 }
             }
@@ -178,7 +168,7 @@ pub fn sub_span_for_meth_name(&self, span: Span) -> Option<Span> {
                 token::OpenDelim(token::Paren) | token::Lt => 1,
                 token::CloseDelim(token::Paren) | token::Gt => -1,
                 token::BinOp(token::Shr) => -2,
-                _ => 0
+                _ => 0,
             };
 
             if prev.tok.is_ident() && bracket_count == 0 {
@@ -202,9 +192,7 @@ pub fn sub_span_for_type_name(&self, span: Span) -> Option<Span> {
         loop {
             let next = toks.real_token();
 
-            if (next.tok == token::Lt ||
-                next.tok == token::Colon) &&
-               bracket_count == 0 &&
+            if (next.tok == token::Lt || next.tok == token::Colon) && bracket_count == 0 &&
                prev.tok.is_ident() {
                 result = Some(prev.sp);
             }
@@ -214,7 +202,7 @@ pub fn sub_span_for_type_name(&self, span: Span) -> Option<Span> {
                 token::Gt => -1,
                 token::BinOp(token::Shl) => 2,
                 token::BinOp(token::Shr) => -2,
-                _ => 0
+                _ => 0,
             };
 
             if next.tok == token::Eof {
@@ -265,7 +253,7 @@ pub fn spans_with_brackets(&self, span: Span, nesting: isize, limit: isize) -> V
                 token::Gt => -1,
                 token::BinOp(token::Shl) => 2,
                 token::BinOp(token::Shr) => -2,
-                _ => 0
+                _ => 0,
             };
 
             // Ignore the `>::` in `<Type as Trait>::AssocTy`.
@@ -316,21 +304,15 @@ pub fn sub_span_of_token(&self, span: Span, tok: Token) -> Option<Span> {
         }
     }
 
-    pub fn sub_span_after_keyword(&self,
-                                  span: Span,
-                                  keyword: keywords::Keyword) -> Option<Span> {
+    pub fn sub_span_after_keyword(&self, span: Span, keyword: keywords::Keyword) -> Option<Span> {
         self.sub_span_after(span, |t| t.is_keyword(keyword))
     }
 
-    pub fn sub_span_after_token(&self,
-                                span: Span,
-                                tok: Token) -> Option<Span> {
+    pub fn sub_span_after_token(&self, span: Span, tok: Token) -> Option<Span> {
         self.sub_span_after(span, |t| t == tok)
     }
 
-    fn sub_span_after<F: Fn(Token) -> bool>(&self,
-                                            span: Span,
-                                            f: F) -> Option<Span> {
+    fn sub_span_after<F: Fn(Token) -> bool>(&self, span: Span, f: F) -> Option<Span> {
         let mut toks = self.retokenise_span(span);
         loop {
             let ts = toks.real_token();