Skip to content

Commit 4b12f70

Browse files
committed
Remove Node* prefix from AnnNode
1 parent befc4b1 commit 4b12f70

File tree

4 files changed

+65
-69
lines changed

4 files changed

+65
-69
lines changed

src/librustc/hir/print.rs

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
pub use self::AnnNode::*;
12-
1311
use rustc_target::spec::abi::Abi;
1412
use syntax::ast;
1513
use syntax::source_map::{SourceMap, Spanned};
@@ -33,12 +31,12 @@ use std::iter::Peekable;
3331
use std::vec;
3432

3533
pub enum AnnNode<'a> {
36-
NodeName(&'a ast::Name),
37-
NodeBlock(&'a hir::Block),
38-
NodeItem(&'a hir::Item),
39-
NodeSubItem(ast::NodeId),
40-
NodeExpr(&'a hir::Expr),
41-
NodePat(&'a hir::Pat),
34+
Name(&'a ast::Name),
35+
Block(&'a hir::Block),
36+
Item(&'a hir::Item),
37+
SubItem(ast::NodeId),
38+
Expr(&'a hir::Expr),
39+
Pat(&'a hir::Pat),
4240
}
4341

4442
pub enum Nested {
@@ -529,7 +527,7 @@ impl<'a> State<'a> {
529527
self.hardbreak_if_not_bol()?;
530528
self.maybe_print_comment(item.span.lo())?;
531529
self.print_outer_attributes(&item.attrs)?;
532-
self.ann.pre(self, NodeItem(item))?;
530+
self.ann.pre(self, AnnNode::Item(item))?;
533531
match item.node {
534532
hir::ItemKind::ExternCrate(orig_name) => {
535533
self.head(&visibility_qualified(&item.vis, "extern crate"))?;
@@ -768,7 +766,7 @@ impl<'a> State<'a> {
768766
self.s.word(";")?;
769767
}
770768
}
771-
self.ann.post(self, NodeItem(item))
769+
self.ann.post(self, AnnNode::Item(item))
772770
}
773771

774772
pub fn print_trait_ref(&mut self, t: &hir::TraitRef) -> io::Result<()> {
@@ -933,7 +931,7 @@ impl<'a> State<'a> {
933931
}
934932

935933
pub fn print_trait_item(&mut self, ti: &hir::TraitItem) -> io::Result<()> {
936-
self.ann.pre(self, NodeSubItem(ti.id))?;
934+
self.ann.pre(self, AnnNode::SubItem(ti.id))?;
937935
self.hardbreak_if_not_bol()?;
938936
self.maybe_print_comment(ti.span.lo())?;
939937
self.print_outer_attributes(&ti.attrs)?;
@@ -965,11 +963,11 @@ impl<'a> State<'a> {
965963
default.as_ref().map(|ty| &**ty))?;
966964
}
967965
}
968-
self.ann.post(self, NodeSubItem(ti.id))
966+
self.ann.post(self, AnnNode::SubItem(ti.id))
969967
}
970968

971969
pub fn print_impl_item(&mut self, ii: &hir::ImplItem) -> io::Result<()> {
972-
self.ann.pre(self, NodeSubItem(ii.id))?;
970+
self.ann.pre(self, AnnNode::SubItem(ii.id))?;
973971
self.hardbreak_if_not_bol()?;
974972
self.maybe_print_comment(ii.span.lo())?;
975973
self.print_outer_attributes(&ii.attrs)?;
@@ -995,7 +993,7 @@ impl<'a> State<'a> {
995993
self.print_associated_type(ii.ident, Some(bounds), None)?;
996994
}
997995
}
998-
self.ann.post(self, NodeSubItem(ii.id))
996+
self.ann.post(self, AnnNode::SubItem(ii.id))
999997
}
1000998

1001999
pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> {
@@ -1055,7 +1053,7 @@ impl<'a> State<'a> {
10551053
hir::DefaultBlock => (),
10561054
}
10571055
self.maybe_print_comment(blk.span.lo())?;
1058-
self.ann.pre(self, NodeBlock(blk))?;
1056+
self.ann.pre(self, AnnNode::Block(blk))?;
10591057
self.bopen()?;
10601058

10611059
self.print_inner_attributes(attrs)?;
@@ -1072,7 +1070,7 @@ impl<'a> State<'a> {
10721070
_ => (),
10731071
}
10741072
self.bclose_maybe_open(blk.span, indented, close_box)?;
1075-
self.ann.post(self, NodeBlock(blk))
1073+
self.ann.post(self, AnnNode::Block(blk))
10761074
}
10771075

10781076
fn print_else(&mut self, els: Option<&hir::Expr>) -> io::Result<()> {
@@ -1321,7 +1319,7 @@ impl<'a> State<'a> {
13211319
self.maybe_print_comment(expr.span.lo())?;
13221320
self.print_outer_attributes(&expr.attrs)?;
13231321
self.ibox(indent_unit)?;
1324-
self.ann.pre(self, NodeExpr(expr))?;
1322+
self.ann.pre(self, AnnNode::Expr(expr))?;
13251323
match expr.node {
13261324
hir::ExprKind::Box(ref expr) => {
13271325
self.word_space("box")?;
@@ -1559,7 +1557,7 @@ impl<'a> State<'a> {
15591557
self.print_expr_maybe_paren(&expr, parser::PREC_JUMP)?;
15601558
}
15611559
}
1562-
self.ann.post(self, NodeExpr(expr))?;
1560+
self.ann.post(self, AnnNode::Expr(expr))?;
15631561
self.end()
15641562
}
15651563

@@ -1606,7 +1604,7 @@ impl<'a> State<'a> {
16061604
} else {
16071605
self.s.word(&ident.as_str())?;
16081606
}
1609-
self.ann.post(self, NodeName(&ident.name))
1607+
self.ann.post(self, AnnNode::Name(&ident.name))
16101608
}
16111609

16121610
pub fn print_name(&mut self, name: ast::Name) -> io::Result<()> {
@@ -1774,7 +1772,7 @@ impl<'a> State<'a> {
17741772

17751773
pub fn print_pat(&mut self, pat: &hir::Pat) -> io::Result<()> {
17761774
self.maybe_print_comment(pat.span.lo())?;
1777-
self.ann.pre(self, NodePat(pat))?;
1775+
self.ann.pre(self, AnnNode::Pat(pat))?;
17781776
// Pat isn't normalized, but the beauty of it
17791777
// is that it doesn't matter
17801778
match pat.node {
@@ -1928,7 +1926,7 @@ impl<'a> State<'a> {
19281926
self.s.word("]")?;
19291927
}
19301928
}
1931-
self.ann.post(self, NodePat(pat))
1929+
self.ann.post(self, AnnNode::Pat(pat))
19321930
}
19331931

19341932
fn print_arm(&mut self, arm: &hir::Arm) -> io::Result<()> {

src/librustc_borrowck/dataflow.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O
117117
ps: &mut pprust::State,
118118
node: pprust::AnnNode) -> io::Result<()> {
119119
let id = match node {
120-
pprust::NodeName(_) => return Ok(()),
121-
pprust::NodeExpr(expr) => expr.hir_id.local_id,
122-
pprust::NodeBlock(blk) => blk.hir_id.local_id,
123-
pprust::NodeItem(_) |
124-
pprust::NodeSubItem(_) => return Ok(()),
125-
pprust::NodePat(pat) => pat.hir_id.local_id
120+
pprust::AnnNode::Name(_) => return Ok(()),
121+
pprust::AnnNode::Expr(expr) => expr.hir_id.local_id,
122+
pprust::AnnNode::Block(blk) => blk.hir_id.local_id,
123+
pprust::AnnNode::Item(_) |
124+
pprust::AnnNode::SubItem(_) => return Ok(()),
125+
pprust::AnnNode::Pat(pat) => pat.hir_id.local_id
126126
};
127127

128128
if !self.has_bitset_for_local_id(id) {

src/librustc_driver/pretty.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -355,33 +355,33 @@ impl<'hir> PrinterSupport for IdentifiedAnnotation<'hir> {
355355
impl<'hir> pprust::PpAnn for IdentifiedAnnotation<'hir> {
356356
fn pre(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> {
357357
match node {
358-
pprust::NodeExpr(_) => s.popen(),
358+
pprust::AnnNode::Expr(_) => s.popen(),
359359
_ => Ok(()),
360360
}
361361
}
362362
fn post(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> {
363363
match node {
364-
pprust::NodeIdent(_) |
365-
pprust::NodeName(_) => Ok(()),
364+
pprust::AnnNode::Ident(_) |
365+
pprust::AnnNode::Name(_) => Ok(()),
366366

367-
pprust::NodeItem(item) => {
367+
pprust::AnnNode::Item(item) => {
368368
s.s.space()?;
369369
s.synth_comment(item.id.to_string())
370370
}
371-
pprust::NodeSubItem(id) => {
371+
pprust::AnnNode::SubItem(id) => {
372372
s.s.space()?;
373373
s.synth_comment(id.to_string())
374374
}
375-
pprust::NodeBlock(blk) => {
375+
pprust::AnnNode::Block(blk) => {
376376
s.s.space()?;
377377
s.synth_comment(format!("block {}", blk.id))
378378
}
379-
pprust::NodeExpr(expr) => {
379+
pprust::AnnNode::Expr(expr) => {
380380
s.s.space()?;
381381
s.synth_comment(expr.id.to_string())?;
382382
s.pclose()
383383
}
384-
pprust::NodePat(pat) => {
384+
pprust::AnnNode::Pat(pat) => {
385385
s.s.space()?;
386386
s.synth_comment(format!("pat {}", pat.id))
387387
}
@@ -414,34 +414,34 @@ impl<'hir> pprust_hir::PpAnn for IdentifiedAnnotation<'hir> {
414414
}
415415
fn pre(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Result<()> {
416416
match node {
417-
pprust_hir::NodeExpr(_) => s.popen(),
417+
pprust_hir::AnnNode::Expr(_) => s.popen(),
418418
_ => Ok(()),
419419
}
420420
}
421421
fn post(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Result<()> {
422422
match node {
423-
pprust_hir::NodeName(_) => Ok(()),
424-
pprust_hir::NodeItem(item) => {
423+
pprust_hir::AnnNode::Name(_) => Ok(()),
424+
pprust_hir::AnnNode::Item(item) => {
425425
s.s.space()?;
426426
s.synth_comment(format!("node_id: {} hir local_id: {}",
427427
item.id, item.hir_id.local_id.0))
428428
}
429-
pprust_hir::NodeSubItem(id) => {
429+
pprust_hir::AnnNode::SubItem(id) => {
430430
s.s.space()?;
431431
s.synth_comment(id.to_string())
432432
}
433-
pprust_hir::NodeBlock(blk) => {
433+
pprust_hir::AnnNode::Block(blk) => {
434434
s.s.space()?;
435435
s.synth_comment(format!("block node_id: {} hir local_id: {}",
436436
blk.id, blk.hir_id.local_id.0))
437437
}
438-
pprust_hir::NodeExpr(expr) => {
438+
pprust_hir::AnnNode::Expr(expr) => {
439439
s.s.space()?;
440440
s.synth_comment(format!("node_id: {} hir local_id: {}",
441441
expr.id, expr.hir_id.local_id.0))?;
442442
s.pclose()
443443
}
444-
pprust_hir::NodePat(pat) => {
444+
pprust_hir::AnnNode::Pat(pat) => {
445445
s.s.space()?;
446446
s.synth_comment(format!("pat node_id: {} hir local_id: {}",
447447
pat.id, pat.hir_id.local_id.0))
@@ -467,13 +467,13 @@ impl<'a> PrinterSupport for HygieneAnnotation<'a> {
467467
impl<'a> pprust::PpAnn for HygieneAnnotation<'a> {
468468
fn post(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> {
469469
match node {
470-
pprust::NodeIdent(&ast::Ident { name, span }) => {
470+
pprust::AnnNode::Ident(&ast::Ident { name, span }) => {
471471
s.s.space()?;
472472
// FIXME #16420: this doesn't display the connections
473473
// between syntax contexts
474474
s.synth_comment(format!("{}{:?}", name.as_u32(), span.ctxt()))
475475
}
476-
pprust::NodeName(&name) => {
476+
pprust::AnnNode::Name(&name) => {
477477
s.s.space()?;
478478
s.synth_comment(name.as_u32().to_string())
479479
}
@@ -519,13 +519,13 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
519519
}
520520
fn pre(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Result<()> {
521521
match node {
522-
pprust_hir::NodeExpr(_) => s.popen(),
522+
pprust_hir::AnnNode::Expr(_) => s.popen(),
523523
_ => Ok(()),
524524
}
525525
}
526526
fn post(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Result<()> {
527527
match node {
528-
pprust_hir::NodeExpr(expr) => {
528+
pprust_hir::AnnNode::Expr(expr) => {
529529
s.s.space()?;
530530
s.s.word("as")?;
531531
s.s.space()?;

0 commit comments

Comments
 (0)