diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index eef7a6f8b4d61..1f16b728cd239 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1877,13 +1877,19 @@ pub struct Variant_ { pub type Variant = Spanned; +/// Part of `use` item to the right of its prefix. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum UseTreeKind { + /// `use prefix` or `use prefix as rename` Simple(Option), + /// `use prefix::{...}` Nested(Vec<(UseTree, NodeId)>), + /// `use prefix::*` Glob, } +/// A tree of paths sharing common prefixes. +/// Used in `use` items both at top-level and inside of braces in import groups. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct UseTree { pub prefix: Path, diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index f42cb8a258314..0aef504534183 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -1438,7 +1438,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: NodeId, _nested: bool) { - if let ast::UseTreeKind::Simple(ident) = use_tree.kind { + if let ast::UseTreeKind::Simple(Some(ident)) = use_tree.kind { if ident.name == "_" { gate_feature_post!(&self, underscore_imports, use_tree.span, "renaming imports with `_` is unstable");