Skip to content

Commit a547962

Browse files
committed
Pretty print ids for assoc items
1 parent d754722 commit a547962

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/librustc/middle/dataflow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O
108108
pprust::NodeIdent(_) | pprust::NodeName(_) => 0,
109109
pprust::NodeExpr(expr) => expr.id,
110110
pprust::NodeBlock(blk) => blk.id,
111-
pprust::NodeItem(_) => 0,
111+
pprust::NodeItem(_) | pprust::NodeSubItem(_) => 0,
112112
pprust::NodePat(pat) => pat.id
113113
};
114114

src/librustc_driver/pretty.rs

+4
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ impl<'ast> pprust::PpAnn for IdentifiedAnnotation<'ast> {
226226
try!(pp::space(&mut s.s));
227227
s.synth_comment(item.id.to_string())
228228
}
229+
pprust::NodeSubItem(id) => {
230+
try!(pp::space(&mut s.s));
231+
s.synth_comment(id.to_string())
232+
}
229233
pprust::NodeBlock(blk) => {
230234
try!(pp::space(&mut s.s));
231235
s.synth_comment(format!("block {}", blk.id))

src/libsyntax/print/pprust.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub enum AnnNode<'a> {
3737
NodeName(&'a ast::Name),
3838
NodeBlock(&'a ast::Block),
3939
NodeItem(&'a ast::Item),
40+
NodeSubItem(ast::NodeId),
4041
NodeExpr(&'a ast::Expr),
4142
NodePat(&'a ast::Pat),
4243
}
@@ -1264,6 +1265,7 @@ impl<'a> State<'a> {
12641265

12651266
pub fn print_trait_item(&mut self, ti: &ast::TraitItem)
12661267
-> io::Result<()> {
1268+
try!(self.ann.pre(self, NodeSubItem(ti.id)));
12671269
try!(self.hardbreak_if_not_bol());
12681270
try!(self.maybe_print_comment(ti.span.lo));
12691271
try!(self.print_outer_attributes(&ti.attrs));
@@ -1275,19 +1277,21 @@ impl<'a> State<'a> {
12751277
try!(self.print_method_sig(ti.ident, sig, ast::Inherited));
12761278
if let Some(ref body) = *body {
12771279
try!(self.nbsp());
1278-
self.print_block_with_attrs(body, &ti.attrs)
1280+
try!(self.print_block_with_attrs(body, &ti.attrs));
12791281
} else {
1280-
word(&mut self.s, ";")
1282+
try!(word(&mut self.s, ";"));
12811283
}
12821284
}
12831285
ast::TypeTraitItem(ref bounds, ref default) => {
1284-
self.print_associated_type(ti.ident, Some(bounds),
1285-
default.as_ref().map(|ty| &**ty))
1286+
try!(self.print_associated_type(ti.ident, Some(bounds),
1287+
default.as_ref().map(|ty| &**ty)));
12861288
}
12871289
}
1290+
self.ann.post(self, NodeSubItem(ti.id))
12881291
}
12891292

12901293
pub fn print_impl_item(&mut self, ii: &ast::ImplItem) -> io::Result<()> {
1294+
try!(self.ann.pre(self, NodeSubItem(ii.id)));
12911295
try!(self.hardbreak_if_not_bol());
12921296
try!(self.maybe_print_comment(ii.span.lo));
12931297
try!(self.print_outer_attributes(&ii.attrs));
@@ -1296,10 +1300,10 @@ impl<'a> State<'a> {
12961300
try!(self.head(""));
12971301
try!(self.print_method_sig(ii.ident, sig, ii.vis));
12981302
try!(self.nbsp());
1299-
self.print_block_with_attrs(body, &ii.attrs)
1303+
try!(self.print_block_with_attrs(body, &ii.attrs));
13001304
}
13011305
ast::TypeImplItem(ref ty) => {
1302-
self.print_associated_type(ii.ident, None, Some(ty))
1306+
try!(self.print_associated_type(ii.ident, None, Some(ty)));
13031307
}
13041308
ast::MacImplItem(codemap::Spanned { node: ast::MacInvocTT(ref pth, ref tts, _),
13051309
..}) => {
@@ -1311,9 +1315,10 @@ impl<'a> State<'a> {
13111315
try!(self.print_tts(&tts[..]));
13121316
try!(self.pclose());
13131317
try!(word(&mut self.s, ";"));
1314-
self.end()
1318+
try!(self.end())
13151319
}
13161320
}
1321+
self.ann.post(self, NodeSubItem(ii.id))
13171322
}
13181323

13191324
pub fn print_outer_attributes(&mut self,

0 commit comments

Comments
 (0)