diff --git a/src/librustc/hir/fold.rs b/src/librustc/hir/fold.rs index 0edfd16bdfd1b7ca07d9e3af5d222e5a44e796d0..5e4ca82dd0090312fdfcfbdb3eb0dbabc3a4ca1e 100644 --- a/src/librustc/hir/fold.rs +++ b/src/librustc/hir/fold.rs @@ -271,16 +271,10 @@ pub fn noop_fold_view_path(view_path: P, fld: &mut T) -> P< ViewPathList(fld.fold_path(path), path_list_idents.move_map(|path_list_ident| { Spanned { - node: match path_list_ident.node { - PathListIdent { id, name, rename } => PathListIdent { - id: fld.new_id(id), - name: name, - rename: rename, - }, - PathListMod { id, rename } => PathListMod { - id: fld.new_id(id), - rename: rename, - }, + node: PathListItem_ { + id: fld.new_id(path_list_ident.node.id), + name: path_list_ident.node.name, + rename: path_list_ident.node.rename, }, span: fld.new_span(path_list_ident.span), } diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 92b956788860ee1058d4c7fb9b773f72b2d70e19..bc1dff7c6fc312e27e08d3fa10b2792ebc110e8d 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -444,12 +444,12 @@ pub fn walk_path<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path) { } } -pub fn walk_path_list_item<'v, V: Visitor<'v>>(visitor: &mut V, - _prefix: &'v Path, - item: &'v PathListItem) { - visitor.visit_id(item.node.id()); - walk_opt_name(visitor, item.span, item.node.name()); - walk_opt_name(visitor, item.span, item.node.rename()); +pub fn walk_path_list_item<'v, V>(visitor: &mut V, _prefix: &'v Path, item: &'v PathListItem) + where V: Visitor<'v>, +{ + visitor.visit_id(item.node.id); + visitor.visit_name(item.span, item.node.name); + walk_opt_name(visitor, item.span, item.node.rename); } pub fn walk_path_segment<'v, V: Visitor<'v>>(visitor: &mut V, diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index afb8f5de8eadded7b66fd69bdcfbe44d66b4087a..691396b9b7751b9a68b1f4509e3f5ac8d026415a 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -218,7 +218,7 @@ fn lower_view_path(&mut self, view_path: &ViewPath) -> P { fn lower_path_list_item(&mut self, path_list_ident: &PathListItem) -> hir::PathListItem { Spanned { - node: hir::PathListIdent { + node: hir::PathListItem_ { id: path_list_ident.node.id, name: path_list_ident.node.name.name, rename: path_list_ident.node.rename.map(|rename| rename.name), diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index b70190181af8fcf80123a70d575af4cc1bda43e9..280c0f304856990810b38169af7f76a4d43b7848 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -120,7 +120,7 @@ fn visit_item(&mut self, i: &'ast Item) { match view_path.node { ViewPathList(_, ref paths) => { for path in paths { - this.insert(path.node.id(), NodeItem(i)); + this.insert(path.node.id, NodeItem(i)); } } _ => () diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index d41cdfabdf4c04a55b841385bb6dccadd131cd39..d6b8a84698a87afa852ea147ff034b851c326975 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -20,7 +20,6 @@ pub use self::ForeignItem_::*; pub use self::Item_::*; pub use self::Mutability::*; -pub use self::PathListItem_::*; pub use self::PrimTy::*; pub use self::Stmt_::*; pub use self::TraitItem_::*; @@ -1337,39 +1336,11 @@ pub struct Variant_ { pub type Variant = Spanned; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] -pub enum PathListItem_ { - PathListIdent { - name: Name, - /// renamed in list, eg `use foo::{bar as baz};` - rename: Option, - id: NodeId, - }, - PathListMod { - /// renamed in list, eg `use foo::{self as baz};` - rename: Option, - id: NodeId, - }, -} - -impl PathListItem_ { - pub fn id(&self) -> NodeId { - match *self { - PathListIdent { id, .. } | PathListMod { id, .. } => id, - } - } - - pub fn name(&self) -> Option { - match *self { - PathListIdent { name, .. } => Some(name), - PathListMod { .. } => None, - } - } - - pub fn rename(&self) -> Option { - match *self { - PathListIdent { rename, .. } | PathListMod { rename, .. } => rename, - } - } +pub struct PathListItem_ { + pub name: Name, + /// renamed in list, eg `use foo::{bar as baz};` + pub rename: Option, + pub id: NodeId, } pub type PathListItem = Spanned; diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 66c1bc7642c56b682ce9da0b33d4844483f4fedc..cdd8a36fbad6c452ab2d8722ce1cca5a4ee3d420 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -2133,16 +2133,7 @@ pub fn print_view_path(&mut self, vp: &hir::ViewPath) -> io::Result<()> { self.print_path(path, false, 0)?; word(&mut self.s, "::{")?; } - self.commasep(Inconsistent, &segments[..], |s, w| { - match w.node { - hir::PathListIdent { name, .. } => { - s.print_name(name) - } - hir::PathListMod { .. } => { - word(&mut s.s, "self") - } - } - })?; + self.commasep(Inconsistent, &segments[..], |s, w| s.print_name(w.node.name))?; word(&mut self.s, "}") } } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 2a8594c59a83764c727862b7f3ff38684154d7e4..cdd774e11d3282ec5e9e586420a6e28b733e42b4 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -294,7 +294,7 @@ fn visit_path(&mut self, path: &hir::Path, id: ast::NodeId) { } fn visit_path_list_item(&mut self, path: &hir::Path, item: &hir::PathListItem) { - self.lookup_and_handle_definition(item.node.id()); + self.lookup_and_handle_definition(item.node.id); intravisit::walk_path_list_item(self, path, item); } } diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index cbbc2c4f98f5e09b025f59756289a153805b0f7d..6a57f510cdd9a2a94a80ba8b96f73d00b30504dd 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -631,7 +631,7 @@ pub fn check_path_list_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cb: &mut FnMut(DefId, Span, &Option<&Stability>, &Option)) { - match tcx.expect_def(item.node.id()) { + match tcx.expect_def(item.node.id) { Def::PrimTy(..) => {} def => { maybe_do_stability_check(tcx, def.def_id(), item.span, cb); diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 57705301aab4e55b27a5edb884c7ad1d9d2e0f5e..1ec0bba5f5bcdfafe48434b806840092885a7c3e 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -20,6 +20,7 @@ use syntax::ast; use syntax::attr::{self, AttrMetaMethods}; use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType}; +use syntax::parse::token::keywords; use syntax::ptr::P; use syntax_pos::Span; @@ -392,13 +393,9 @@ impl LateLintPass for UnusedImportBraces { fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { if let hir::ItemUse(ref view_path) = item.node { if let hir::ViewPathList(_, ref items) = view_path.node { - if items.len() == 1 { - if let hir::PathListIdent {ref name, ..} = items[0].node { - let m = format!("braces around {} is unnecessary", - name); - cx.span_lint(UNUSED_IMPORT_BRACES, item.span, - &m[..]); - } + if items.len() == 1 && items[0].node.name != keywords::SelfValue.name() { + let msg = format!("braces around {} is unnecessary", items[0].node.name); + cx.span_lint(UNUSED_IMPORT_BRACES, item.span, &msg); } } } diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 2ee0927f3c8ea44e5d8d945aab7fabf0a1c0bff5..f66f15b238e73fd8eba05395546d54cad68b8cd3 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -49,7 +49,7 @@ fn visit_item(&mut self, item: &hir::Item) { } hir::ViewPathList(_, ref path_list) => { for path_item in path_list { - self.check_import(path_item.node.id(), path_item.span); + self.check_import(path_item.node.id, path_item.span); } } }