Skip to content

Commit edca8f7

Browse files
committed
rustfmt librustc_trans/save
1 parent 668dac4 commit edca8f7

File tree

4 files changed

+118
-177
lines changed

4 files changed

+118
-177
lines changed

src/librustc_trans/save/dump_csv.rs

Lines changed: 46 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,29 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> {
7171
span: SpanUtils<'l>,
7272
fmt: FmtStrs<'l>,
7373

74-
cur_scope: NodeId
74+
cur_scope: NodeId,
7575
}
7676

7777
impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
7878
pub fn new(tcx: &'l ty::ctxt<'tcx>,
7979
analysis: &'l ty::CrateAnalysis,
80-
output_file: Box<File>) -> DumpCsvVisitor<'l, 'tcx> {
80+
output_file: Box<File>)
81+
-> DumpCsvVisitor<'l, 'tcx> {
8182
let span_utils = SpanUtils::new(&tcx.sess);
8283
DumpCsvVisitor {
8384
sess: &tcx.sess,
8485
tcx: tcx,
8586
save_ctxt: SaveContext::from_span_utils(tcx, span_utils.clone()),
8687
analysis: analysis,
8788
span: span_utils.clone(),
88-
fmt: FmtStrs::new(box Recorder {
89-
out: output_file,
90-
dump_spans: false,
91-
}, span_utils),
92-
cur_scope: 0
89+
fmt: FmtStrs::new(box Recorder { out: output_file, dump_spans: false },
90+
span_utils),
91+
cur_scope: 0,
9392
}
9493
}
9594

96-
fn nest<F>(&mut self, scope_id: NodeId, f: F) where
97-
F: FnOnce(&mut DumpCsvVisitor<'l, 'tcx>),
95+
fn nest<F>(&mut self, scope_id: NodeId, f: F)
96+
where F: FnOnce(&mut DumpCsvVisitor<'l, 'tcx>)
9897
{
9998
let parent_scope = self.cur_scope;
10099
self.cur_scope = scope_id;
@@ -140,9 +139,11 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
140139
let mut segs = vec!();
141140
for (i, (seg, span)) in path.segments.iter().zip(&spans).enumerate() {
142141
segs.push(seg.clone());
143-
let sub_path = ast::Path{span: *span, // span for the last segment
144-
global: path.global,
145-
segments: segs};
142+
let sub_path = ast::Path {
143+
span: *span, // span for the last segment
144+
global: path.global,
145+
segments: segs,
146+
};
146147
let qualname = if i == 0 && path.global {
147148
format!("::{}", path_to_string(&sub_path))
148149
} else {
@@ -271,7 +272,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
271272
def::DefPrimTy(_) => {
272273
self.sess.span_bug(span, &format!("lookup_def_kind for unexpected item: {:?}",
273274
def));
274-
},
275+
}
275276
}
276277
}
277278

@@ -357,9 +358,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
357358
}
358359
}
359360

360-
fn process_struct_field_def(&mut self,
361-
field: &ast::StructField,
362-
parent_id: NodeId) {
361+
fn process_struct_field_def(&mut self, field: &ast::StructField, parent_id: NodeId) {
363362
let field_data = self.save_ctxt.get_field_data(field, parent_id);
364363
if let Some(field_data) = field_data {
365364
self.fmt.field_str(field.span,
@@ -374,7 +373,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
374373

375374
// Dump generic params bindings, then visit_generics
376375
fn process_generic_params(&mut self,
377-
generics:&ast::Generics,
376+
generics: &ast::Generics,
378377
full_span: Span,
379378
prefix: &str,
380379
id: NodeId) {
@@ -427,11 +426,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
427426
self.nest(item.id, |v| v.visit_block(&body));
428427
}
429428

430-
fn process_static_or_const_item(&mut self,
431-
item: &ast::Item,
432-
typ: &ast::Ty,
433-
expr: &ast::Expr)
434-
{
429+
fn process_static_or_const_item(&mut self, item: &ast::Item, typ: &ast::Ty, expr: &ast::Expr) {
435430
let var_data = self.save_ctxt.get_item_data(item);
436431
down_cast_data!(var_data, VariableData, self, item.span);
437432
self.fmt.static_str(item.span,
@@ -452,8 +447,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
452447
ident: &ast::Ident,
453448
span: Span,
454449
typ: &ast::Ty,
455-
expr: &ast::Expr)
456-
{
450+
expr: &ast::Expr) {
457451
let qualname = format!("::{}", self.tcx.map.path_to_string(id));
458452

459453
let sub_span = self.span.sub_span_after_keyword(span,
@@ -641,8 +635,8 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
641635
sub_span,
642636
id,
643637
item.id);
644-
},
645-
None => ()
638+
}
639+
None => (),
646640
}
647641
}
648642

@@ -653,8 +647,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
653647
}
654648
}
655649

656-
fn process_mod(&mut self,
657-
item: &ast::Item) { // The module in question, represented as an item.
650+
fn process_mod(&mut self, item: &ast::Item) { // The module in question, represented as an item.
658651
let mod_data = self.save_ctxt.get_item_data(item);
659652
down_cast_data!(mod_data, ModData, self, item.span);
660653
self.fmt.mod_str(item.span,
@@ -665,10 +658,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
665658
&mod_data.filename);
666659
}
667660

668-
fn process_path(&mut self,
669-
id: NodeId,
670-
path: &ast::Path,
671-
ref_kind: Option<recorder::Row>) {
661+
fn process_path(&mut self, id: NodeId, path: &ast::Path, ref_kind: Option<recorder::Row>) {
672662
if generated_code(path.span) {
673663
return;
674664
}
@@ -737,7 +727,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
737727
def::DefStruct(_) |
738728
def::DefVariant(..) |
739729
def::DefFn(..) => self.write_sub_paths_truncated(path, false),
740-
_ => {},
730+
_ => {}
741731
}
742732
}
743733

@@ -783,9 +773,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
783773
visit::walk_expr_opt(self, base)
784774
}
785775

786-
fn process_method_call(&mut self,
787-
ex: &ast::Expr,
788-
args: &Vec<P<ast::Expr>>) {
776+
fn process_method_call(&mut self, ex: &ast::Expr, args: &Vec<P<ast::Expr>>) {
789777
if let Some(call_data) = self.save_ctxt.get_expr_data(ex) {
790778
down_cast_data!(call_data, MethodCallData, self, ex.span);
791779
self.fmt.meth_call_str(ex.span,
@@ -799,7 +787,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
799787
visit::walk_exprs(self, &args);
800788
}
801789

802-
fn process_pat(&mut self, p:&ast::Pat) {
790+
fn process_pat(&mut self, p: &ast::Pat) {
803791
if generated_code(p.span) {
804792
return;
805793
}
@@ -827,7 +815,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
827815
self.visit_pat(&field.pat);
828816
}
829817
}
830-
_ => visit::walk_pat(self, p)
818+
_ => visit::walk_pat(self, p),
831819
}
832820
}
833821
}
@@ -851,10 +839,10 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
851839
sub_span,
852840
def_id,
853841
self.cur_scope),
854-
None => {},
842+
None => {}
855843
}
856844
Some(def_id)
857-
},
845+
}
858846
None => None,
859847
};
860848

@@ -902,20 +890,19 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
902890
match plid.node {
903891
ast::PathListIdent { id, .. } => {
904892
match self.lookup_type_ref(id) {
905-
Some(def_id) =>
906-
match self.lookup_def_kind(id, plid.span) {
907-
Some(kind) => {
908-
self.fmt.ref_str(
893+
Some(def_id) => match self.lookup_def_kind(id, plid.span) {
894+
Some(kind) => {
895+
self.fmt.ref_str(
909896
kind, plid.span,
910897
Some(plid.span),
911898
def_id, self.cur_scope);
912-
}
913-
None => ()
914-
},
915-
None => ()
899+
}
900+
None => (),
901+
},
902+
None => (),
916903
}
917-
},
918-
ast::PathListMod { .. } => ()
904+
}
905+
ast::PathListMod { .. } => (),
919906
}
920907
}
921908

@@ -978,7 +965,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
978965

979966
self.visit_ty(&**ty);
980967
self.process_generic_params(ty_params, item.span, &qualname, item.id);
981-
},
968+
}
982969
ast::ItemMac(_) => (),
983970
_ => visit::walk_item(self, item),
984971
}
@@ -1048,14 +1035,14 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
10481035
sub_span,
10491036
id,
10501037
self.cur_scope);
1051-
},
1052-
None => ()
1038+
}
1039+
None => (),
10531040
}
10541041

10551042
self.write_sub_paths_truncated(path, false);
10561043

10571044
visit::walk_path(self, path);
1058-
},
1045+
}
10591046
_ => visit::walk_ty(self, t),
10601047
}
10611048
}
@@ -1101,7 +1088,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
11011088
field_data.ref_id,
11021089
field_data.scope);
11031090
}
1104-
},
1091+
}
11051092
ast::ExprTupField(ref sub_ex, idx) => {
11061093
if generated_code(sub_ex.span) {
11071094
return
@@ -1125,7 +1112,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
11251112
&format!("Expected struct or tuple \
11261113
type, found {:?}", ty)),
11271114
}
1128-
},
1115+
}
11291116
ast::ExprClosure(_, ref decl, ref body) => {
11301117
if generated_code(body.span) {
11311118
return
@@ -1146,7 +1133,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
11461133

11471134
// walk the body
11481135
self.nest(ex.id, |v| v.visit_block(&**body));
1149-
},
1136+
}
11501137
_ => {
11511138
visit::walk_expr(self, ex)
11521139
}
@@ -1182,7 +1169,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
11821169
}
11831170
let def = def_map.get(&id).unwrap().full_def();
11841171
match def {
1185-
def::DefLocal(id) => {
1172+
def::DefLocal(id) => {
11861173
let value = if immut == ast::MutImmutable {
11871174
self.span.snippet(p.span).to_string()
11881175
} else {
@@ -1205,7 +1192,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
12051192
def::DefConst(..) |
12061193
def::DefAssociatedConst(..) => {}
12071194
_ => error!("unexpected definition kind when processing collected paths: {:?}",
1208-
def)
1195+
def),
12091196
}
12101197
}
12111198

0 commit comments

Comments
 (0)