]> git.lizzy.rs Git - rust.git/commitdiff
Store `Ident` rather than just `Name` in HIR types `Item` and `ForeignItem`.
authorAlexander Regueiro <alexreg@me.com>
Sat, 1 Dec 2018 02:47:08 +0000 (02:47 +0000)
committerAlexander Regueiro <alexreg@me.com>
Wed, 26 Dec 2018 21:26:37 +0000 (21:26 +0000)
38 files changed:
src/libproc_macro/bridge/rpc.rs
src/librustc/hir/intravisit.rs
src/librustc/hir/lowering.rs
src/librustc/hir/map/blocks.rs
src/librustc/hir/map/mod.rs
src/librustc/hir/mod.rs
src/librustc/hir/print.rs
src/librustc/ich/impls_hir.rs
src/librustc/middle/dead.rs
src/librustc/middle/entry.rs
src/librustc/mir/mod.rs
src/librustc/ty/layout.rs
src/librustc/ty/mod.rs
src/librustc_codegen_llvm/debuginfo/metadata.rs
src/librustc_codegen_llvm/type_of.rs
src/librustc_driver/test.rs
src/librustc_lint/nonstandard_style.rs
src/librustc_lint/types.rs
src/librustc_metadata/decoder.rs
src/librustc_mir/hair/pattern/check_match.rs
src/librustc_mir/hair/pattern/mod.rs
src/librustc_mir/interpret/validity.rs
src/librustc_resolve/macros.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/intrinsic.rs
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check_unused.rs
src/librustc_typeck/collect.rs
src/librustdoc/clean/mod.rs
src/librustdoc/passes/collect_intra_doc_links.rs
src/librustdoc/test.rs
src/librustdoc/visit_ast.rs
src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs [new file with mode: 0644]
src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs
src/test/ui-fulldeps/lint-group-plugin.rs
src/test/ui-fulldeps/lint-group-plugin.stderr

index ed5136462cf3d7425155650cb09d842b7187d71e..6685aa1acac39d6bbedfad66b51c058bd17729e7 100644 (file)
@@ -1,4 +1,4 @@
-//! Serialization for client<->server communication.
+//! Serialization for client-server communication.
 
 use std::any::Any;
 use std::char;
index 17b001a5ce8ac7f49263d8bfcf1fe31c51d94b0d..d6b94052d1d5eda31a80810d2330b62357d5cb48 100644 (file)
@@ -454,7 +454,7 @@ pub fn walk_trait_ref<'v, V>(visitor: &mut V, trait_ref: &'v TraitRef)
 
 pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
     visitor.visit_vis(&item.vis);
-    visitor.visit_name(item.span, item.name);
+    visitor.visit_ident(item.ident);
     match item.node {
         ItemKind::ExternCrate(orig_name) => {
             visitor.visit_id(item.id);
@@ -472,7 +472,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
             visitor.visit_nested_body(body);
         }
         ItemKind::Fn(ref declaration, header, ref generics, body_id) => {
-            visitor.visit_fn(FnKind::ItemFn(item.name,
+            visitor.visit_fn(FnKind::ItemFn(item.ident.name,
                                             generics,
                                             header,
                                             &item.vis,
@@ -528,7 +528,8 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
         ItemKind::Union(ref struct_definition, ref generics) => {
             visitor.visit_generics(generics);
             visitor.visit_id(item.id);
-            visitor.visit_variant_data(struct_definition, item.name, generics, item.id, item.span);
+            visitor.visit_variant_data(struct_definition, item.ident.name, generics, item.id,
+                                       item.span);
         }
         ItemKind::Trait(.., ref generics, ref bounds, ref trait_item_refs) => {
             visitor.visit_id(item.id);
@@ -569,9 +570,9 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
                                         variant: &'v Variant,
                                         generics: &'v Generics,
                                         parent_item_id: NodeId) {
-    visitor.visit_name(variant.span, variant.node.name);
+    visitor.visit_ident(variant.node.ident);
     visitor.visit_variant_data(&variant.node.data,
-                               variant.node.name,
+                               variant.node.ident.name,
                                generics,
                                parent_item_id,
                                variant.span);
@@ -720,7 +721,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
 pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v ForeignItem) {
     visitor.visit_id(foreign_item.id);
     visitor.visit_vis(&foreign_item.vis);
-    visitor.visit_name(foreign_item.span, foreign_item.name);
+    visitor.visit_ident(foreign_item.ident);
 
     match foreign_item.node {
         ForeignItemKind::Fn(ref function_declaration, ref param_names, ref generics) => {
index 039b525c8644a3cdcdc83df50ff53523814412e3..545a5024c5288061bb6d3831d78b4a762b9f9e34 100644 (file)
@@ -1360,7 +1360,7 @@ fn lower_existential_impl_trait(
             let exist_ty_item = hir::Item {
                 id: exist_ty_id.node_id,
                 hir_id: exist_ty_id.hir_id,
-                name: keywords::Invalid.name(),
+                ident: keywords::Invalid.ident(),
                 attrs: Default::default(),
                 node: exist_ty_item_kind,
                 vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited),
@@ -1563,7 +1563,7 @@ fn lower_global_asm(&mut self, ga: &GlobalAsm) -> P<hir::GlobalAsm> {
     fn lower_variant(&mut self, v: &Variant) -> hir::Variant {
         Spanned {
             node: hir::VariantKind {
-                name: v.node.ident.name,
+                ident: v.node.ident,
                 attrs: self.lower_attrs(&v.node.attrs),
                 data: self.lower_variant_data(&v.node.data),
                 disr_expr: v.node.disr_expr.as_ref().map(|e| self.lower_anon_const(e)),
@@ -2738,7 +2738,7 @@ fn lower_async_body(
     fn lower_item_kind(
         &mut self,
         id: NodeId,
-        name: &mut Name,
+        ident: &mut Ident,
         attrs: &hir::HirVec<Attribute>,
         vis: &mut hir::Visibility,
         i: &ItemKind,
@@ -2752,7 +2752,7 @@ fn lower_item_kind(
                     span: use_tree.span,
                 };
 
-                self.lower_use_tree(use_tree, &prefix, id, vis, name, attrs)
+                self.lower_use_tree(use_tree, &prefix, id, vis, ident, attrs)
             }
             ItemKind::Static(ref t, m, ref e) => {
                 let value = self.lower_body(None, |this| this.lower_expr(e));
@@ -2944,7 +2944,7 @@ fn lower_use_tree(
         prefix: &Path,
         id: NodeId,
         vis: &mut hir::Visibility,
-        name: &mut Name,
+        ident: &mut Ident,
         attrs: &hir::HirVec<Attribute>,
     ) -> hir::ItemKind {
         debug!("lower_use_tree(tree={:?})", tree);
@@ -2960,28 +2960,28 @@ fn lower_use_tree(
 
         match tree.kind {
             UseTreeKind::Simple(rename, id1, id2) => {
-                *name = tree.ident().name;
+                *ident = tree.ident();
 
-                // First apply the prefix to the path
+                // First, apply the prefix to the path.
                 let mut path = Path {
                     segments,
                     span: path.span,
                 };
 
-                // Correctly resolve `self` imports
+                // Correctly resolve `self` imports.
                 if path.segments.len() > 1
                     && path.segments.last().unwrap().ident.name == keywords::SelfLower.name()
                 {
                     let _ = path.segments.pop();
                     if rename.is_none() {
-                        *name = path.segments.last().unwrap().ident.name;
+                        *ident = path.segments.last().unwrap().ident;
                     }
                 }
 
                 let parent_def_index = self.current_hir_id_owner.last().unwrap().0;
                 let mut defs = self.expect_full_def_from_use(id);
-                // we want to return *something* from this function, so hang onto the first item
-                // for later
+                // We want to return *something* from this function, so hold onto the first item
+                // for later.
                 let ret_def = defs.next().unwrap_or(Def::Err);
 
                 // Here, we are looping over namespaces, if they exist for the definition
@@ -2991,7 +2991,7 @@ fn lower_use_tree(
                 // two imports.
                 for (def, &new_node_id) in defs.zip([id1, id2].iter()) {
                     let vis = vis.clone();
-                    let name = name.clone();
+                    let ident = ident.clone();
                     let mut path = path.clone();
                     for seg in &mut path.segments {
                         seg.id = self.sess.next_node_id();
@@ -3032,7 +3032,7 @@ fn lower_use_tree(
                             hir::Item {
                                 id: new_id.node_id,
                                 hir_id: new_id.hir_id,
-                                name: name,
+                                ident,
                                 attrs: attrs.clone(),
                                 node: item,
                                 vis,
@@ -3058,8 +3058,8 @@ fn lower_use_tree(
                 hir::ItemKind::Use(path, hir::UseKind::Glob)
             }
             UseTreeKind::Nested(ref trees) => {
-                // Nested imports are desugared into simple
-                // imports. So if we start with
+                // Nested imports are desugared into simple imports.
+                // So, if we start with
                 //
                 // ```
                 // pub(x) use foo::{a, b};
@@ -3080,14 +3080,14 @@ fn lower_use_tree(
                 // `self.items`. However, the structure of this
                 // function also requires us to return one item, and
                 // for that we return the `{}` import (called the
-                // "`ListStem`").
+                // `ListStem`).
 
                 let prefix = Path {
                     segments,
                     span: prefix.span.to(path.span),
                 };
 
-                // Add all the nested PathListItems to the HIR.
+                // Add all the nested `PathListItem`s to the HIR.
                 for &(ref use_tree, id) in trees {
                     self.allocate_hir_id_counter(id, &use_tree);
 
@@ -3097,10 +3097,10 @@ fn lower_use_tree(
                     } = self.lower_node_id(id);
 
                     let mut vis = vis.clone();
-                    let mut name = name.clone();
+                    let mut ident = ident.clone();
                     let mut prefix = prefix.clone();
 
-                    // Give the segments new ids since they are being cloned.
+                    // Give the segments new node-ids since they are being cloned.
                     for seg in &mut prefix.segments {
                         seg.id = self.sess.next_node_id();
                     }
@@ -3115,7 +3115,7 @@ fn lower_use_tree(
                                                        &prefix,
                                                        new_id,
                                                        &mut vis,
-                                                       &mut name,
+                                                       &mut ident,
                                                        attrs);
 
                         let vis_kind = match vis.node {
@@ -3139,7 +3139,7 @@ fn lower_use_tree(
                             hir::Item {
                                 id: new_id,
                                 hir_id: new_hir_id,
-                                name,
+                                ident,
                                 attrs: attrs.clone(),
                                 node: item,
                                 vis,
@@ -3166,7 +3166,7 @@ fn lower_use_tree(
                         *vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited);
                     }
                     hir::VisibilityKind::Restricted { .. } => {
-                        // do nothing here, as described in the comment on the match
+                        // Do nothing here, as described in the comment on the match.
                     }
                 }
 
@@ -3414,7 +3414,7 @@ fn lower_item_id_use_tree(&mut self,
     }
 
     pub fn lower_item(&mut self, i: &Item) -> Option<hir::Item> {
-        let mut name = i.ident.name;
+        let mut ident = i.ident;
         let mut vis = self.lower_visibility(&i.vis, None);
         let attrs = self.lower_attrs(&i.attrs);
         if let ItemKind::MacroDef(ref def) = i.node {
@@ -3422,7 +3422,7 @@ pub fn lower_item(&mut self, i: &Item) -> Option<hir::Item> {
                               attr::contains_name(&i.attrs, "rustc_doc_only_macro") {
                 let body = self.lower_token_stream(def.stream());
                 self.exported_macros.push(hir::MacroDef {
-                    name,
+                    name: ident.name,
                     vis,
                     attrs,
                     id: i.id,
@@ -3434,14 +3434,14 @@ pub fn lower_item(&mut self, i: &Item) -> Option<hir::Item> {
             return None;
         }
 
-        let node = self.lower_item_kind(i.id, &mut name, &attrs, &mut vis, &i.node);
+        let node = self.lower_item_kind(i.id, &mut ident, &attrs, &mut vis, &i.node);
 
         let LoweredNodeId { node_id, hir_id } = self.lower_node_id(i.id);
 
         Some(hir::Item {
             id: node_id,
             hir_id,
-            name,
+            ident,
             attrs,
             node,
             vis,
@@ -3454,7 +3454,7 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem {
         let def_id = self.resolver.definitions().local_def_id(node_id);
         hir::ForeignItem {
             id: node_id,
-            name: i.ident.name,
+            ident: i.ident,
             attrs: self.lower_attrs(&i.attrs),
             node: match i.node {
                 ForeignItemKind::Fn(ref fdec, ref generics) => {
index 895e1e782ab6ec411879bac6290528b8fc72d0cd..837a20ac0f2f02590b8cab93b62580817d7206d7 100644 (file)
@@ -228,7 +228,7 @@ fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
                 ast::ItemKind::Fn(ref decl, header, ref generics, block) =>
                     item_fn(ItemFnParts {
                         id: i.id,
-                        name: i.name,
+                        name: i.ident.name,
                         decl: &decl,
                         body: block,
                         vis: &i.vis,
index d7c51f1e5fd36ca849ae9cd01bba8bf54ab5836c..188d487d6448545769960dd1f7af71e1f8aaaf14 100644 (file)
@@ -813,11 +813,11 @@ pub fn expect_expr(&self, id: NodeId) -> &'hir Expr {
     /// Returns the name associated with the given NodeId's AST.
     pub fn name(&self, id: NodeId) -> Name {
         match self.get(id) {
-            Node::Item(i) => i.name,
-            Node::ForeignItem(i) => i.name,
+            Node::Item(i) => i.ident.name,
+            Node::ForeignItem(fi) => fi.ident.name,
             Node::ImplItem(ii) => ii.ident.name,
             Node::TraitItem(ti) => ti.ident.name,
-            Node::Variant(v) => v.node.name,
+            Node::Variant(v) => v.node.ident.name,
             Node::Field(f) => f.ident.name,
             Node::Lifetime(lt) => lt.name.ident().name,
             Node::GenericParam(param) => param.name.ident().name,
@@ -953,7 +953,7 @@ fn find_first_mod_parent<'a>(map: &'a Map<'_>, mut id: NodeId) -> Option<(NodeId
             loop {
                 if let Node::Item(item) = map.find(id)? {
                     if item_is_mod(&item) {
-                        return Some((id, item.name))
+                        return Some((id, item.ident.name))
                     }
                 }
                 let parent = map.get_parent(id);
@@ -1009,9 +1009,9 @@ trait Named {
 
 impl<T:Named> Named for Spanned<T> { fn name(&self) -> Name { self.node.name() } }
 
-impl Named for Item { fn name(&self) -> Name { self.name } }
-impl Named for ForeignItem { fn name(&self) -> Name { self.name } }
-impl Named for VariantKind { fn name(&self) -> Name { self.name } }
+impl Named for Item { fn name(&self) -> Name { self.ident.name } }
+impl Named for ForeignItem { fn name(&self) -> Name { self.ident.name } }
+impl Named for VariantKind { fn name(&self) -> Name { self.ident.name } }
 impl Named for StructField { fn name(&self) -> Name { self.ident.name } }
 impl Named for TraitItem { fn name(&self) -> Name { self.ident.name } }
 impl Named for ImplItem { fn name(&self) -> Name { self.ident.name } }
@@ -1194,7 +1194,7 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String {
         }
         Some(Node::Variant(ref variant)) => {
             format!("variant {} in {}{}",
-                    variant.node.name,
+                    variant.node.ident,
                     path_str(), id_str)
         }
         Some(Node::Field(ref field)) => {
index 30817433823a8160519394771b1e9b1a26111683..f92ac4f74c3d7faabb76ef7ba5e13c7ceaf915c9 100644 (file)
@@ -2015,7 +2015,7 @@ pub struct EnumDef {
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct VariantKind {
-    pub name: Name,
+    pub ident: Ident,
     pub attrs: HirVec<Attribute>,
     pub data: VariantData,
     /// Explicit discriminant, e.g., `Foo = 1`
@@ -2176,7 +2176,7 @@ pub struct ItemId {
 /// The name might be a dummy name in case of anonymous items
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct Item {
-    pub name: Name,
+    pub ident: Ident,
     pub id: NodeId,
     pub hir_id: HirId,
     pub attrs: HirVec<Attribute>,
@@ -2331,7 +2331,7 @@ pub enum AssociatedItemKind {
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct ForeignItem {
-    pub name: Name,
+    pub ident: Ident,
     pub attrs: HirVec<Attribute>,
     pub node: ForeignItemKind,
     pub id: NodeId,
index 9c869998d54f44bdf65a91066f5e7c7f54c0b23b..423dbab879d2d164045bf31d83176b82b1b10e97 100644 (file)
@@ -450,7 +450,7 @@ pub fn print_foreign_item(&mut self, item: &hir::ForeignItem) -> io::Result<()>
                                   abi: Abi::Rust,
                                   asyncness: hir::IsAsync::NotAsync,
                               },
-                              Some(item.name),
+                              Some(item.ident.name),
                               generics,
                               &item.vis,
                               arg_names,
@@ -464,7 +464,7 @@ pub fn print_foreign_item(&mut self, item: &hir::ForeignItem) -> io::Result<()>
                 if m {
                     self.word_space("mut")?;
                 }
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.word_space(":")?;
                 self.print_type(&t)?;
                 self.s.word(";")?;
@@ -473,7 +473,7 @@ pub fn print_foreign_item(&mut self, item: &hir::ForeignItem) -> io::Result<()>
             }
             hir::ForeignItemKind::Type => {
                 self.head(visibility_qualified(&item.vis, "type"))?;
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.s.word(";")?;
                 self.end()?; // end the head-ibox
                 self.end() // end the outer cbox
@@ -533,7 +533,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
                     self.s.word("as")?;
                     self.s.space()?;
                 }
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.s.word(";")?;
                 self.end()?; // end inner head-block
                 self.end()?; // end outer head-block
@@ -544,10 +544,10 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
 
                 match kind {
                     hir::UseKind::Single => {
-                        if path.segments.last().unwrap().ident.name != item.name {
+                        if path.segments.last().unwrap().ident != item.ident {
                             self.s.space()?;
                             self.word_space("as")?;
-                            self.print_name(item.name)?;
+                            self.print_ident(item.ident)?;
                         }
                         self.s.word(";")?;
                     }
@@ -562,7 +562,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
                 if m == hir::MutMutable {
                     self.word_space("mut")?;
                 }
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.word_space(":")?;
                 self.print_type(&ty)?;
                 self.s.space()?;
@@ -575,7 +575,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
             }
             hir::ItemKind::Const(ref ty, expr) => {
                 self.head(visibility_qualified(&item.vis, "const"))?;
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.word_space(":")?;
                 self.print_type(&ty)?;
                 self.s.space()?;
@@ -590,7 +590,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
                 self.head("")?;
                 self.print_fn(decl,
                               header,
-                              Some(item.name),
+                              Some(item.ident.name),
                               typarams,
                               &item.vis,
                               &[],
@@ -602,7 +602,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
             }
             hir::ItemKind::Mod(ref _mod) => {
                 self.head(visibility_qualified(&item.vis, "mod"))?;
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.nbsp()?;
                 self.bopen()?;
                 self.print_mod(_mod, &item.attrs)?;
@@ -622,7 +622,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
             }
             hir::ItemKind::Ty(ref ty, ref generics) => {
                 self.head(visibility_qualified(&item.vis, "type"))?;
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.print_generic_params(&generics.params)?;
                 self.end()?; // end the inner ibox
 
@@ -635,7 +635,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
             }
             hir::ItemKind::Existential(ref exist) => {
                 self.head(visibility_qualified(&item.vis, "existential type"))?;
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.print_generic_params(&exist.generics.params)?;
                 self.end()?; // end the inner ibox
 
@@ -657,15 +657,16 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
                 self.end()?; // end the outer ibox
             }
             hir::ItemKind::Enum(ref enum_definition, ref params) => {
-                self.print_enum_def(enum_definition, params, item.name, item.span, &item.vis)?;
+                self.print_enum_def(enum_definition, params, item.ident.name, item.span,
+                                    &item.vis)?;
             }
             hir::ItemKind::Struct(ref struct_def, ref generics) => {
                 self.head(visibility_qualified(&item.vis, "struct"))?;
-                self.print_struct(struct_def, generics, item.name, item.span, true)?;
+                self.print_struct(struct_def, generics, item.ident.name, item.span, true)?;
             }
             hir::ItemKind::Union(ref struct_def, ref generics) => {
                 self.head(visibility_qualified(&item.vis, "union"))?;
-                self.print_struct(struct_def, generics, item.name, item.span, true)?;
+                self.print_struct(struct_def, generics, item.ident.name, item.span, true)?;
             }
             hir::ItemKind::Impl(unsafety,
                           polarity,
@@ -712,7 +713,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
                 self.print_is_auto(is_auto)?;
                 self.print_unsafety(unsafety)?;
                 self.word_nbsp("trait")?;
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.print_generic_params(&generics.params)?;
                 let mut real_bounds = Vec::with_capacity(bounds.len());
                 for b in bounds.iter() {
@@ -737,7 +738,7 @@ pub fn print_item(&mut self, item: &hir::Item) -> io::Result<()> {
                 self.head("")?;
                 self.print_visibility(&item.vis)?;
                 self.word_nbsp("trait")?;
-                self.print_name(item.name)?;
+                self.print_ident(item.ident)?;
                 self.print_generic_params(&generics.params)?;
                 let mut real_bounds = Vec::with_capacity(bounds.len());
                 // FIXME(durka) this seems to be some quite outdated syntax
@@ -895,7 +896,7 @@ pub fn print_struct(&mut self,
     pub fn print_variant(&mut self, v: &hir::Variant) -> io::Result<()> {
         self.head("")?;
         let generics = hir::Generics::empty();
-        self.print_struct(&v.node.data, &generics, v.node.name, v.span, false)?;
+        self.print_struct(&v.node.data, &generics, v.node.ident.name, v.span, false)?;
         if let Some(ref d) = v.node.disr_expr {
             self.s.space()?;
             self.word_space("=")?;
index f5d6827e89b4965b354383844d1a69fe11e09718..9bf82baa68758d307d3263b451397e9c3584acab 100644 (file)
@@ -818,7 +818,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl_stable_hash_for!(struct hir::VariantKind {
-    name,
+    ident -> (ident.name),
     attrs,
     data,
     disr_expr
@@ -852,7 +852,7 @@ fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a>,
                                           hasher: &mut StableHasher<W>) {
         let hir::Item {
-            name,
+            ident,
             ref attrs,
             id: _,
             hir_id: _,
@@ -862,7 +862,7 @@ fn hash_stable<W: StableHasherResult>(&self,
         } = *self;
 
         hcx.hash_hir_item_like(|hcx| {
-            name.hash_stable(hcx, hasher);
+            ident.name.hash_stable(hcx, hasher);
             attrs.hash_stable(hcx, hasher);
             node.hash_stable(hcx, hasher);
             vis.hash_stable(hcx, hasher);
@@ -926,7 +926,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 impl_stable_hash_for!(struct hir::ForeignItem {
-    name,
+    ident -> (ident.name),
     attrs,
     node,
     id,
index 3cc9bffa9a423b6dbd13990a2de0445757fe6e8d..0c769c91801b8a9ff3cb2ccf96dbbeb22695cb08 100644 (file)
@@ -557,7 +557,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             self.warn_dead_code(
                 item.id,
                 span,
-                item.name,
+                item.ident.name,
                 item.node.descriptive_variant(),
                 participle,
             );
@@ -572,7 +572,7 @@ fn visit_variant(&mut self,
                      g: &'tcx hir::Generics,
                      id: ast::NodeId) {
         if self.should_warn_about_variant(&variant.node) {
-            self.warn_dead_code(variant.node.data.id(), variant.span, variant.node.name,
+            self.warn_dead_code(variant.node.data.id(), variant.span, variant.node.ident.name,
                                 "variant", "constructed");
         } else {
             intravisit::walk_variant(self, variant, g, id);
@@ -581,7 +581,7 @@ fn visit_variant(&mut self,
 
     fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem) {
         if self.should_warn_about_foreign_item(fi) {
-            self.warn_dead_code(fi.id, fi.span, fi.name,
+            self.warn_dead_code(fi.id, fi.span, fi.ident.name,
                                 fi.node.descriptive_variant(), "used");
         }
         intravisit::walk_foreign_item(self, fi);
index 2add525f0940da123f21ecee554f73267fe82137..6b593a1a9f9b248a56abbafc8c027f15cec4d522 100644 (file)
@@ -86,7 +86,7 @@ fn entry_point_type(item: &Item, at_root: bool) -> EntryPointType {
                 EntryPointType::Start
             } else if attr::contains_name(&item.attrs, "main") {
                 EntryPointType::MainAttr
-            } else if item.name == "main" {
+            } else if item.ident.name == "main" {
                 if at_root {
                     // This is a top-level function so can be 'main'.
                     EntryPointType::MainNamed
index f774b13f98301741ff830df3aac030332655151e..36d51c5971278cd41c3dd80407bd85739513eac8 100644 (file)
@@ -2040,7 +2040,7 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
             Promoted(ref promoted) => write!(fmt, "({:?}: {:?})", promoted.0, promoted.1),
             Projection(ref data) => match data.elem {
                 ProjectionElem::Downcast(ref adt_def, index) => {
-                    write!(fmt, "({:?} as {})", data.base, adt_def.variants[index].name)
+                    write!(fmt, "({:?} as {})", data.base, adt_def.variants[index].ident)
                 }
                 ProjectionElem::Deref => write!(fmt, "(*{:?})", data.base),
                 ProjectionElem::Field(field, ty) => {
index a5331cbbdb0e5002cfb1560deb098e9902e3996c..171c53b7b20ba7e56082b85c2257a200327e325b 100644 (file)
@@ -1,7 +1,7 @@
 use session::{self, DataTypeKind};
 use ty::{self, Ty, TyCtxt, TypeFoldable, ReprOptions};
 
-use syntax::ast::{self, IntTy, UintTy};
+use syntax::ast::{self, Ident, IntTy, UintTy};
 use syntax::attr;
 use syntax_pos::DUMMY_SP;
 
@@ -1228,7 +1228,7 @@ fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) {
         let adt_kind = adt_def.adt_kind();
         let adt_packed = adt_def.repr.packed();
 
-        let build_variant_info = |n: Option<ast::Name>,
+        let build_variant_info = |n: Option<Ident>,
                                   flds: &[ast::Name],
                                   layout: TyLayout<'tcx>| {
             let mut min_size = Size::ZERO;
@@ -1273,7 +1273,7 @@ fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) {
         match layout.variants {
             Variants::Single { index } => {
                 debug!("print-type-size `{:#?}` variant {}",
-                       layout, adt_def.variants[index].name);
+                       layout, adt_def.variants[index].ident);
                 if !adt_def.variants.is_empty() {
                     let variant_def = &adt_def.variants[index];
                     let fields: Vec<_> =
@@ -1281,7 +1281,7 @@ fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) {
                     record(adt_kind.into(),
                            adt_packed,
                            None,
-                           vec![build_variant_info(Some(variant_def.name),
+                           vec![build_variant_info(Some(variant_def.ident),
                                                    &fields,
                                                    layout)]);
                 } else {
@@ -1299,7 +1299,7 @@ fn record_layout_for_printing_outlined(&self, layout: TyLayout<'tcx>) {
                     adt_def.variants.iter_enumerated().map(|(i, variant_def)| {
                         let fields: Vec<_> =
                             variant_def.fields.iter().map(|f| f.ident.name).collect();
-                        build_variant_info(Some(variant_def.name),
+                        build_variant_info(Some(variant_def.ident),
                                            &fields,
                                            layout.for_variant(self, i))
                     })
index 2256cd4364b708f17f23cd41f71f0dc44526a735..b484e015672125bf27ff38449290faab65f9c498 100644 (file)
@@ -1773,7 +1773,7 @@ pub struct VariantDef {
     /// The variant's `DefId`. If this is a tuple-like struct,
     /// this is the `DefId` of the struct's ctor.
     pub did: DefId,
-    pub name: Name, // struct's name if this is a struct
+    pub ident: Ident, // struct's name if this is a struct
     pub discr: VariantDiscr,
     pub fields: Vec<FieldDef>,
     pub ctor_kind: CtorKind,
@@ -1797,7 +1797,7 @@ impl<'a, 'gcx, 'tcx> VariantDef {
     /// remove this hack and use the constructor DefId everywhere.
     pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                did: DefId,
-               name: Name,
+               ident: Ident,
                discr: VariantDiscr,
                fields: Vec<FieldDef>,
                adt_kind: AdtKind,
@@ -1805,7 +1805,7 @@ pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                attribute_def_id: DefId)
                -> Self
     {
-        debug!("VariantDef::new({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?})", did, name, discr,
+        debug!("VariantDef::new({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?})", did, ident, discr,
                fields, adt_kind, ctor_kind, attribute_def_id);
         let mut flags = VariantFlags::NO_VARIANT_FLAGS;
         if adt_kind == AdtKind::Struct && tcx.has_attr(attribute_def_id, "non_exhaustive") {
@@ -1814,7 +1814,7 @@ pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
         }
         VariantDef {
             did,
-            name,
+            ident,
             discr,
             fields,
             ctor_kind,
@@ -1830,7 +1830,7 @@ pub fn is_field_list_non_exhaustive(&self) -> bool {
 
 impl_stable_hash_for!(struct VariantDef {
     did,
-    name,
+    ident -> (ident.name),
     discr,
     fields,
     ctor_kind,
@@ -1971,8 +1971,6 @@ pub struct ReprFlags: u8 {
     bits
 });
 
-
-
 /// Represents the repr options provided by the user,
 #[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, Default)]
 pub struct ReprOptions {
index 3be784ccc04b09e41ba439c4360dac8e73e9db9c..0fd04e9d20393ccebf7fd688de88220ac00f3357 100644 (file)
@@ -1215,7 +1215,7 @@ fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
                         name: if fallback {
                             String::new()
                         } else {
-                            adt.variants[index].name.as_str().to_string()
+                            adt.variants[index].ident.as_str().to_string()
                         },
                         type_metadata: variant_type_metadata,
                         offset: Size::ZERO,
@@ -1255,7 +1255,7 @@ fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>)
                         name: if fallback {
                             String::new()
                         } else {
-                            adt.variants[i].name.as_str().to_string()
+                            adt.variants[i].ident.as_str().to_string()
                         },
                         type_metadata: variant_type_metadata,
                         offset: Size::ZERO,
@@ -1321,7 +1321,7 @@ fn compute_field_path<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
                                        self.layout,
                                        self.layout.fields.offset(0),
                                        self.layout.field(cx, 0).size);
-                    name.push_str(&adt.variants[*niche_variants.start()].name.as_str());
+                    name.push_str(&adt.variants[*niche_variants.start()].ident.as_str());
 
                     // Create the (singleton) list of descriptions of union members.
                     vec![
@@ -1365,7 +1365,7 @@ fn compute_field_path<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
                         };
 
                         MemberDescription {
-                            name: adt.variants[i].name.as_str().to_string(),
+                            name: adt.variants[i].ident.as_str().to_string(),
                             type_metadata: variant_type_metadata,
                             offset: Size::ZERO,
                             size: self.layout.size,
@@ -1433,7 +1433,7 @@ fn describe_enum_variant(
     containing_scope: &'ll DIScope,
     span: Span,
 ) -> (&'ll DICompositeType, MemberDescriptionFactory<'ll, 'tcx>) {
-    let variant_name = variant.name.as_str();
+    let variant_name = variant.ident.as_str();
     let unique_type_id = debug_context(cx).type_map
                                           .borrow_mut()
                                           .get_unique_type_id_of_enum_variant(
@@ -1527,7 +1527,7 @@ fn prepare_enum_metadata(
         let enumerators_metadata: Vec<_> = def.discriminants(cx.tcx)
             .zip(&def.variants)
             .map(|((_, discr), v)| {
-                let name = SmallCStr::new(&v.name.as_str());
+                let name = SmallCStr::new(&v.ident.as_str());
                 unsafe {
                     Some(llvm::LLVMRustDIBuilderCreateEnumerator(
                         DIB(cx),
index bac2294bd31c7e3392db99f010c8a5914d6a6b98..97128c2d2a2ce519ab709d49a7a87ce4b2f38bd7 100644 (file)
@@ -60,7 +60,7 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
                  = (&layout.ty.sty, &layout.variants)
             {
                 if def.is_enum() && !def.variants.is_empty() {
-                    write!(&mut name, "::{}", def.variants[index].name).unwrap();
+                    write!(&mut name, "::{}", def.variants[index].ident).unwrap();
                 }
             }
             Some(name)
index a8cc401ac38ee937f7c6088cae561f95aef559bc..a5f7d676862e08b1ca0b41a2966a4fa0ddac5941 100644 (file)
@@ -261,7 +261,7 @@ fn search_mod(
             assert!(idx < names.len());
             for item in &m.item_ids {
                 let item = this.infcx.tcx.hir().expect_item(item.id);
-                if item.name.to_string() == names[idx] {
+                if item.ident.to_string() == names[idx] {
                     return search(this, item, idx + 1, names);
                 }
             }
index e425d2cdae9a7cc69fb7b3ff790d593b806f8a75..2694a04b94ce4c3106bdd2f81486325e6b0026da 100644 (file)
@@ -278,7 +278,7 @@ fn check_fn(&mut self,
 
     fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         if let hir::ItemKind::Mod(_) = it.node {
-            self.check_snake_case(cx, "module", &it.name.as_str(), Some(it.span));
+            self.check_snake_case(cx, "module", &it.ident.as_str(), Some(it.span));
         }
     }
 
@@ -354,10 +354,12 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
                 if attr::find_by_name(&it.attrs, "no_mangle").is_some() {
                     return;
                 }
-                NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.name, it.span);
+                NonUpperCaseGlobals::check_upper_case(cx, "static variable", it.ident.name,
+                                                      it.span);
             }
             hir::ItemKind::Const(..) => {
-                NonUpperCaseGlobals::check_upper_case(cx, "constant", it.name, it.span);
+                NonUpperCaseGlobals::check_upper_case(cx, "constant", it.ident.name,
+                                                      it.span);
             }
             _ => {}
         }
index 65e1b9ff7628b567a5bab8b31821798ad3645ed2..642681a73a8a0a57c2f878efdffe9ce7b4bf78f7 100644 (file)
@@ -837,7 +837,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
                                 let bytes = variant_layout.size.bytes().saturating_sub(discr_size);
 
                                 debug!("- variant `{}` is {} bytes large",
-                                       variant.node.name,
+                                       variant.node.ident,
                                        bytes);
                                 bytes
                             })
index 687753bd8de0812352ea8bd8baaec7c63682e292..dc8db5be5820ab4024778b5c224cc07ad3f49bfc 100644 (file)
@@ -553,7 +553,7 @@ fn get_variant(&self,
         ty::VariantDef::new(
             tcx,
             def_id,
-            self.item_name(index).as_symbol(),
+            Ident::from_interned_str(self.item_name(index)),
             data.discr,
             item.children.decode(self).map(|index| {
                 let f = self.entry(index);
index 50d861b674cef6ffcb8dbd5796a5f1c763429ff2..f758e488877158ace2e54508113ca17dd908cac1 100644 (file)
@@ -306,7 +306,7 @@ fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor, pat: &Pat) {
                 let pat_ty = cx.tables.pat_ty(p);
                 if let ty::Adt(edef, _) = pat_ty.sty {
                     if edef.is_enum() && edef.variants.iter().any(|variant| {
-                        variant.name == ident.name && variant.ctor_kind == CtorKind::Const
+                        variant.ident == ident && variant.ctor_kind == CtorKind::Const
                     }) {
                         let ty_path = cx.tcx.item_path_str(edef.did);
                         let mut err = struct_span_warn!(cx.tcx.sess, p.span, E0170,
index 92da0563d8091d9bcd35cc15306c54f73e826815..62ec52aac134605238e442c4661383277d8d261e 100644 (file)
@@ -280,7 +280,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 let mut start_or_continue = || if first { first = false; "" } else { ", " };
 
                 if let Some(variant) = variant {
-                    write!(f, "{}", variant.name)?;
+                    write!(f, "{}", variant.ident)?;
 
                     // Only for Adt we can have `S {...}`,
                     // which we handle separately here.
index 5e006e20e4785c94fd96b86bdd4d899f7eba31f5..a5fb44587400a1323e412e3a061967f19189fcdb 100644 (file)
@@ -246,7 +246,7 @@ fn visit_variant(
         variant_id: VariantIdx,
         new_op: OpTy<'tcx, M::PointerTag>
     ) -> EvalResult<'tcx> {
-        let name = old_op.layout.ty.ty_adt_def().unwrap().variants[variant_id].name;
+        let name = old_op.layout.ty.ty_adt_def().unwrap().variants[variant_id].ident.name;
         self.visit_elem(new_op, PathElem::Variant(name))
     }
 
index 98c6773cec323d6307122458cad753a40f0a8e65..a851d384d78f3ca64868e4c88e35b6a4eb9e61f1 100644 (file)
@@ -276,7 +276,7 @@ fn resolve_macro_to_def(
                     let features = self.session.features_untracked();
                     if attr_kind == NonMacroAttrKind::Custom {
                         assert!(path.segments.len() == 1);
-                        let name = path.segments[0].ident.name.as_str();
+                        let name = path.segments[0].ident.as_str();
                         if name.starts_with("rustc_") {
                             if !features.rustc_attrs {
                                 let msg = "unless otherwise specified, attributes with the prefix \
index 736b416dd4f214ac6a25b609ed0f3e644ade098b..f33060dde4f15cb818616a583da8ac4c21292b1e 100644 (file)
@@ -1322,8 +1322,8 @@ pub fn associated_path_def_to_ty(&self,
                     span,
                     &format!("no variant `{}` on enum `{}`", &assoc_name.as_str(), ty_str),
                 );
-                // Check if it was a typo
-                let input = adt_def.variants.iter().map(|variant| &variant.name);
+                // Check if it was a typo.
+                let input = adt_def.variants.iter().map(|variant| &variant.ident.name);
                 if let Some(suggested_name) = find_best_match_for_name(
                     input,
                     &assoc_name.as_str(),
index f227c529cb035c152d9f79bd4206fac95a5c21b7..4e3cb5c7f1c0d6d4665156a99dfcc35b1cede231 100644 (file)
@@ -952,7 +952,7 @@ fn check_struct_pat_fields(&self,
                 if plural == "" {
                     let input = unmentioned_fields.iter().map(|field| &field.name);
                     let suggested_name =
-                        find_best_match_for_name(input, &ident.name.as_str(), None);
+                        find_best_match_for_name(input, &ident.as_str(), None);
                     if let Some(suggested_name) = suggested_name {
                         err.span_suggestion(*span, "did you mean", suggested_name.to_string());
                         // we don't want to throw `E0027` in case we have thrown `E0026` for them
index c80990a0704bd58a93f88c9d0005dbb6a5cb65a1..a36b21921436ecaf9cba86641274bdfbd891e4ed 100644 (file)
@@ -71,7 +71,7 @@ fn equate_intrinsic_type<'a, 'tcx>(
 pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                       it: &hir::ForeignItem) {
     let param = |n| tcx.mk_ty_param(n, Symbol::intern(&format!("P{}", n)).as_interned_str());
-    let name = it.name.as_str();
+    let name = it.ident.as_str();
 
     let mk_va_list_ty = || {
         tcx.lang_items().va_list().map(|did| {
@@ -393,7 +393,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
     let def_id = tcx.hir().local_def_id(it.id);
     let i_n_tps = tcx.generics_of(def_id).own_counts().types;
-    let name = it.name.as_str();
+    let name = it.ident.as_str();
 
     let (n_tps, inputs, output) = match &*name {
         "simd_eq" | "simd_ne" | "simd_lt" | "simd_le" | "simd_gt" | "simd_ge" => {
index c4a908d56f351ffe7c1cfb1b2d4190cd64212849..65a58d345ccfa076b1c1e020ba1f229f54ccf1b8 100644 (file)
@@ -185,7 +185,7 @@ pub fn report_method_error(&self,
                     "method"
                 } else if actual.is_enum() {
                     if let Adt(ref adt_def, _) = actual.sty {
-                        let names = adt_def.variants.iter().map(|s| &s.name);
+                        let names = adt_def.variants.iter().map(|s| &s.ident.name);
                         suggestion = find_best_match_for_name(names,
                                                               &item_name.as_str(),
                                                               None);
index 15a9ba99fa711020699b93f7aeb9c0c6845d1648..414cc363f97a1cf4ac1554296ef25a900d82eea3 100644 (file)
@@ -1327,7 +1327,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite
         }
         hir::ItemKind::Fn(..) => {} // entirely within check_item_body
         hir::ItemKind::Impl(.., ref impl_item_refs) => {
-            debug!("ItemKind::Impl {} with id {}", it.name, it.id);
+            debug!("ItemKind::Impl {} with id {}", it.ident, it.id);
             let impl_def_id = tcx.hir().local_def_id(it.id);
             if let Some(impl_trait_ref) = tcx.impl_trait_ref(impl_def_id) {
                 check_impl_items_against_trait(
@@ -3529,7 +3529,7 @@ fn report_unknown_field(&self,
                 ty::Adt(adt, ..) if adt.is_enum() => {
                     struct_span_err!(self.tcx.sess, field.ident.span, E0559,
                                      "{} `{}::{}` has no field named `{}`",
-                                     kind_name, actual, variant.name, field.ident)
+                                     kind_name, actual, variant.ident, field.ident)
                 }
                 _ => {
                     struct_span_err!(self.tcx.sess, field.ident.span, E0560,
@@ -3551,7 +3551,7 @@ fn report_unknown_field(&self,
                     if adt.is_enum() {
                         err.span_label(field.ident.span,
                                        format!("`{}::{}` does not have this field",
-                                               ty, variant.name));
+                                               ty, variant.ident));
                     } else {
                         err.span_label(field.ident.span,
                                        format!("`{}` does not have this field", ty));
@@ -4813,13 +4813,13 @@ pub fn get_fn_decl(&self, blk_id: ast::NodeId) -> Option<(hir::FnDecl, bool)> {
             let parent = self.tcx.hir().get(fn_id);
 
             if let Node::Item(&hir::Item {
-                name, node: hir::ItemKind::Fn(ref decl, ..), ..
+                ident, node: hir::ItemKind::Fn(ref decl, ..), ..
             }) = parent {
                 decl.clone().and_then(|decl| {
                     // This is less than ideal, it will not suggest a return type span on any
                     // method called `main`, regardless of whether it is actually the entry point,
                     // but it will still present it as the reason for the expected type.
-                    Some((decl, name != Symbol::intern("main")))
+                    Some((decl, ident.name != Symbol::intern("main")))
                 })
             } else if let Node::TraitItem(&hir::TraitItem {
                 node: hir::TraitItemKind::Method(hir::MethodSig {
index 740e64b1895e8eb4c27ee39a6cd55ad7c27f074a..bf767726ef715d9f2321aecf4c6fd1c4c7ae9999 100644 (file)
@@ -154,7 +154,7 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
 
         // If the extern crate isn't in the extern prelude,
         // there is no way it can be written as an `use`.
-        let orig_name = extern_crate.orig_name.unwrap_or(item.name);
+        let orig_name = extern_crate.orig_name.unwrap_or(item.ident.name);
         if !tcx.extern_prelude.get(&orig_name).map_or(false, |from_item| !from_item) {
             continue;
         }
@@ -173,8 +173,8 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
             visibility_qualified(&item.vis, "use")
         );
         let base_replacement = match extern_crate.orig_name {
-            Some(orig_name) => format!("use {} as {};", orig_name, item.name),
-            None => format!("use {};", item.name),
+            Some(orig_name) => format!("use {} as {};", orig_name, item.ident.name),
+            None => format!("use {};", item.ident.name),
         };
         let replacement = visibility_qualified(&item.vis, base_replacement);
         tcx.struct_span_lint_node(lint, id, extern_crate.span, msg)
@@ -219,7 +219,7 @@ fn visit_item(&mut self, item: &hir::Item) {
                     def_id: extern_crate_def_id,
                     span: item.span,
                     orig_name,
-                    warn_if_unused: !item.name.as_str().starts_with('_'),
+                    warn_if_unused: !item.ident.as_str().starts_with('_'),
                 }
             );
         }
index a46309c5ea14fca13d8b4e1ea6b6b0557892a0ae..1aede7cf14c3cf8858df3f7012182b4098978fde 100644 (file)
@@ -33,7 +33,7 @@
 use rustc_target::spec::abi;
 
 use syntax::ast;
-use syntax::ast::MetaItemKind;
+use syntax::ast::{Ident, MetaItemKind};
 use syntax::attr::{InlineAttr, list_contains_name, mark_used};
 use syntax::source_map::Spanned;
 use syntax::feature_gate;
@@ -385,7 +385,7 @@ fn is_param<'a, 'tcx>(
 
 fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
     let it = tcx.hir().expect_item(item_id);
-    debug!("convert: item {} with id {}", it.name, it.id);
+    debug!("convert: item {} with id {}", it.ident, it.id);
     let def_id = tcx.hir().local_def_id(item_id);
     match it.node {
         // These don't define types.
@@ -533,7 +533,7 @@ fn convert_enum_variant_types<'a, 'tcx>(
                     format!("overflowed on value after {}", prev_discr.unwrap()),
                 ).note(&format!(
                     "explicitly set `{} = {}` if that is desired outcome",
-                    variant.node.name, wrapped_discr
+                    variant.node.ident, wrapped_discr
                 ))
                 .emit();
                 None
@@ -556,7 +556,7 @@ fn convert_enum_variant_types<'a, 'tcx>(
 fn convert_variant<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     did: DefId,
-    name: ast::Name,
+    ident: Ident,
     discr: ty::VariantDiscr,
     def: &hir::VariantData,
     adt_kind: ty::AdtKind,
@@ -593,12 +593,13 @@ fn convert_variant<'a, 'tcx>(
         .collect();
     ty::VariantDef::new(tcx,
         did,
-        name,
+        ident,
         discr,
         fields,
         adt_kind,
         CtorKind::from_hir(def),
-        attribute_def_id)
+        attribute_def_id
+    )
 }
 
 fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::AdtDef {
@@ -628,7 +629,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
                         };
                         distance_from_explicit += 1;
 
-                        convert_variant(tcx, did, v.node.name, discr, &v.node.data, AdtKind::Enum,
+                        convert_variant(tcx, did, v.node.ident, discr, &v.node.data, AdtKind::Enum,
                                         did)
                     })
                     .collect(),
@@ -646,7 +647,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
                 std::iter::once(convert_variant(
                     tcx,
                     ctor_id.unwrap_or(def_id),
-                    item.name,
+                    item.ident,
                     ty::VariantDiscr::Relative(0),
                     def,
                     AdtKind::Struct,
@@ -659,7 +660,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
             std::iter::once(convert_variant(
                 tcx,
                 def_id,
-                item.name,
+                item.ident,
                 ty::VariantDiscr::Relative(0),
                 def,
                 AdtKind::Union,
index 54d3e640ec58597b0967e16e4cfb270616d31f15..38b2452b420e943eb387832cb3faf0c19bcfcbbf 100644 (file)
@@ -2967,7 +2967,7 @@ fn clean(&self, cx: &DocContext) -> Item {
             }
         };
         Item {
-            name: Some(self.name.clean(cx)),
+            name: Some(self.ident.clean(cx)),
             attrs: inline::load_attrs(cx, self.did),
             source: cx.tcx.def_span(self.did).clean(cx),
             visibility: Some(Inherited),
@@ -3183,13 +3183,22 @@ fn qpath_to_string(p: &hir::QPath) -> String {
     s
 }
 
+impl Clean<String> for Ident {
+    #[inline]
+    fn clean(&self, cx: &DocContext) -> String {
+        self.name.clean(cx)
+    }
+}
+
 impl Clean<String> for ast::Name {
+    #[inline]
     fn clean(&self, _: &DocContext) -> String {
         self.to_string()
     }
 }
 
 impl Clean<String> for InternedString {
+    #[inline]
     fn clean(&self, _: &DocContext) -> String {
         self.to_string()
     }
@@ -3616,7 +3625,7 @@ fn clean(&self, cx: &DocContext) -> Item {
         };
 
         Item {
-            name: Some(self.name.clean(cx)),
+            name: Some(self.ident.clean(cx)),
             attrs: self.attrs.clean(cx),
             source: self.span.clean(cx),
             def_id: cx.tcx.hir().local_def_id(self.id),
@@ -3951,7 +3960,7 @@ pub fn path_to_def_local(tcx: &TyCtxt, path: &[&str]) -> Option<DefId> {
 
         for item_id in mem::replace(&mut items, HirVec::new()).iter() {
             let item = tcx.hir().expect_item(item_id.id);
-            if item.name == *segment {
+            if item.ident.name == *segment {
                 if path_it.peek().is_none() {
                     return Some(tcx.hir().local_def_id(item_id.id))
                 }
index b8ec7e4bd32abd4ebcbce5d49e2515f54a3cb32d..fdc1c0616187a8ed61acb26ad09afd2241d67a42 100644 (file)
@@ -632,7 +632,7 @@ fn handle_variant(cx: &DocContext, def: Def) -> Result<(Def, Option<String>), ()
     };
     let parent_def = Def::Enum(parent);
     let variant = cx.tcx.expect_variant_def(def);
-    Ok((parent_def, Some(format!("{}.v", variant.name))))
+    Ok((parent_def, Some(format!("{}.v", variant.ident.name))))
 }
 
 const PRIMITIVES: &[(&str, Def)] = &[
index 4d870daac4d039c338a4a5a55f7c08966d5f5584..24bb00f4112421a116862882156a1c111792e22b 100644 (file)
@@ -811,7 +811,7 @@ fn visit_item(&mut self, item: &'hir hir::Item) {
         let name = if let hir::ItemKind::Impl(.., ref ty, _) = item.node {
             self.map.node_to_pretty_string(ty.id)
         } else {
-            item.name.to_string()
+            item.ident.to_string()
         };
 
         self.visit_testable(name, &item.attrs, |this| {
@@ -832,7 +832,7 @@ fn visit_impl_item(&mut self, item: &'hir hir::ImplItem) {
     }
 
     fn visit_foreign_item(&mut self, item: &'hir hir::ForeignItem) {
-        self.visit_testable(item.name.to_string(), &item.attrs, |this| {
+        self.visit_testable(item.ident.to_string(), &item.attrs, |this| {
             intravisit::walk_foreign_item(this, item);
         });
     }
@@ -841,7 +841,7 @@ fn visit_variant(&mut self,
                      v: &'hir hir::Variant,
                      g: &'hir hir::Generics,
                      item_id: ast::NodeId) {
-        self.visit_testable(v.node.name.to_string(), &v.node.attrs, |this| {
+        self.visit_testable(v.node.ident.to_string(), &v.node.attrs, |this| {
             intravisit::walk_variant(this, v, g, item_id);
         });
     }
index ffdc048a30ece5ea4be2504ea4a709f4789e6b05..953ab7c2565bfab9a1eafce0c6668d5156b38d33 100644 (file)
@@ -139,7 +139,7 @@ pub fn visit_enum_def(&mut self, it: &hir::Item,
         Enum {
             name,
             variants: def.variants.iter().map(|v| Variant {
-                name: v.node.name,
+                name: v.node.ident.name,
                 attrs: v.node.attrs.clone(),
                 stab: self.stability(v.node.data.id()),
                 depr: self.deprecation(v.node.data.id()),
@@ -263,7 +263,7 @@ pub fn visit_mod_contents(&mut self, span: Span, attrs: hir::HirVec<ast::Attribu
     fn maybe_inline_local(&mut self,
                           id: ast::NodeId,
                           def: Def,
-                          renamed: Option<ast::Name>,
+                          renamed: Option<ast::Ident>,
                           glob: bool,
                           om: &mut Module,
                           please_inline: bool) -> bool {
@@ -357,14 +357,14 @@ fn inherits_doc_hidden(cx: &core::DocContext, mut node: ast::NodeId) -> bool {
                 om.foreigns.push(hir::ForeignMod {
                     abi: tcx.hir().get_foreign_abi(it.id),
                     items: vec![hir::ForeignItem {
-                        name: renamed.unwrap_or(it.name),
+                        ident: renamed.unwrap_or(it.ident),
                         .. it.clone()
                     }].into(),
                 });
                 true
             }
             Node::MacroDef(def) if !glob => {
-                om.macros.push(self.visit_local_macro(def, renamed));
+                om.macros.push(self.visit_local_macro(def, renamed.map(|i| i.name)));
                 true
             }
             _ => false,
@@ -374,9 +374,9 @@ fn inherits_doc_hidden(cx: &core::DocContext, mut node: ast::NodeId) -> bool {
     }
 
     pub fn visit_item(&mut self, item: &hir::Item,
-                      renamed: Option<ast::Name>, om: &mut Module) {
+                      renamed: Option<ast::Ident>, om: &mut Module) {
         debug!("Visiting item {:?}", item);
-        let name = renamed.unwrap_or(item.name);
+        let ident = renamed.unwrap_or(item.ident);
 
         if item.vis.node.is_pub() {
             let def_id = self.cx.tcx.hir().local_def_id(item.id);
@@ -403,7 +403,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
                 om.extern_crates.push(ExternCrate {
                     cnum: self.cx.tcx.extern_mod_stmt_cnum(def_id)
                                 .unwrap_or(LOCAL_CRATE),
-                    name,
+                    name: ident.name,
                     path: orig_name.map(|x|x.to_string()),
                     vis: item.vis.clone(),
                     attrs: item.attrs.clone(),
@@ -433,10 +433,10 @@ pub fn visit_item(&mut self, item: &hir::Item,
                             _ => false,
                         }
                     });
-                    let name = if is_glob { None } else { Some(name) };
+                    let ident = if is_glob { None } else { Some(ident) };
                     if self.maybe_inline_local(item.id,
                                                path.def,
-                                               name,
+                                               ident,
                                                is_glob,
                                                om,
                                                please_inline) {
@@ -445,7 +445,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
                 }
 
                 om.imports.push(Import {
-                    name,
+                    name: ident.name,
                     id: item.id,
                     vis: item.vis.clone(),
                     attrs: item.attrs.clone(),
@@ -460,21 +460,21 @@ pub fn visit_item(&mut self, item: &hir::Item,
                                                      item.vis.clone(),
                                                      item.id,
                                                      m,
-                                                     Some(name)));
+                                                     Some(ident.name)));
             },
             hir::ItemKind::Enum(ref ed, ref gen) =>
-                om.enums.push(self.visit_enum_def(item, name, ed, gen)),
+                om.enums.push(self.visit_enum_def(item, ident.name, ed, gen)),
             hir::ItemKind::Struct(ref sd, ref gen) =>
-                om.structs.push(self.visit_variant_data(item, name, sd, gen)),
+                om.structs.push(self.visit_variant_data(item, ident.name, sd, gen)),
             hir::ItemKind::Union(ref sd, ref gen) =>
-                om.unions.push(self.visit_union_data(item, name, sd, gen)),
+                om.unions.push(self.visit_union_data(item, ident.name, sd, gen)),
             hir::ItemKind::Fn(ref fd, header, ref gen, body) =>
-                self.visit_fn(om, item, name, &**fd, header, gen, body),
+                self.visit_fn(om, item, ident.name, &**fd, header, gen, body),
             hir::ItemKind::Ty(ref ty, ref gen) => {
                 let t = Typedef {
                     ty: ty.clone(),
                     gen: gen.clone(),
-                    name,
+                    name: ident.name,
                     id: item.id,
                     attrs: item.attrs.clone(),
                     whence: item.span,
@@ -487,7 +487,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
             hir::ItemKind::Existential(ref exist_ty) => {
                 let t = Existential {
                     exist_ty: exist_ty.clone(),
-                    name,
+                    name: ident.name,
                     id: item.id,
                     attrs: item.attrs.clone(),
                     whence: item.span,
@@ -503,7 +503,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
                     mutability: mut_.clone(),
                     expr: exp.clone(),
                     id: item.id,
-                    name,
+                    name: ident.name,
                     attrs: item.attrs.clone(),
                     whence: item.span,
                     vis: item.vis.clone(),
@@ -517,7 +517,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
                     type_: ty.clone(),
                     expr: exp.clone(),
                     id: item.id,
-                    name,
+                    name: ident.name,
                     attrs: item.attrs.clone(),
                     whence: item.span,
                     vis: item.vis.clone(),
@@ -533,7 +533,7 @@ pub fn visit_item(&mut self, item: &hir::Item,
                 let t = Trait {
                     is_auto,
                     unsafety,
-                    name,
+                    name: ident.name,
                     items,
                     generics: gen.clone(),
                     bounds: b.iter().cloned().collect(),
diff --git a/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs b/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs
new file mode 100644 (file)
index 0000000..efef4ab
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// force-host
+
+#![feature(plugin_registrar)]
+#![feature(box_syntax, rustc_private)]
+
+// Load rustc as a plugin to get macros.
+#[macro_use]
+extern crate rustc;
+extern crate rustc_plugin;
+
+use rustc::hir;
+use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray};
+use rustc_plugin::Registry;
+
+declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
+
+declare_lint!(PLEASE_LINT, Warn, "Warn about items named 'pleaselintme'");
+
+struct Pass;
+
+impl LintPass for Pass {
+    fn get_lints(&self) -> LintArray {
+        lint_array!(TEST_LINT, PLEASE_LINT)
+    }
+}
+
+impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
+    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+        match &*it.ident.as_str() {
+            "lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"),
+            "pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"),
+            _ => {}
+        }
+    }
+}
+
+#[plugin_registrar]
+pub fn plugin_registrar(reg: &mut Registry) {
+    reg.register_late_lint_pass(box Pass);
+    reg.register_lint_group("lint_me", None, vec![TEST_LINT, PLEASE_LINT]);
+}
index 91d03d98a10b987059f5fbc356c44c83ccbf4b57..bca1d7a72b4abc77cb687271b5e9732976662f7e 100644 (file)
@@ -3,7 +3,7 @@
 #![feature(plugin_registrar)]
 #![feature(box_syntax, rustc_private)]
 
-// Load rustc as a plugin to get macros
+// Load rustc as a plugin to get macros.
 #[macro_use]
 extern crate rustc;
 extern crate rustc_plugin;
@@ -26,7 +26,7 @@ fn get_lints(&self) -> LintArray {
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
     fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
-        match &*it.name.as_str() {
+        match &*it.ident.as_str() {
             "lintme" => cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'"),
             "pleaselintme" => cx.span_lint(PLEASE_LINT, it.span, "item is named 'pleaselintme'"),
             _ => {}
index 00c5a56a482c1063f15d4bd551e6751a43acac85..7a650afe5f8fa89123ca2f48e33b4d2b7a622590 100644 (file)
@@ -1,6 +1,7 @@
 // run-pass
 // aux-build:lint_group_plugin_test.rs
 // ignore-stage1
+
 #![feature(plugin)]
 #![plugin(lint_group_plugin_test)]
 #![allow(dead_code)]
index 15cffedcc5d3c57087d75615c97bd6fc0a58690c..b566048c75ee658a84651a90b16461680afff402 100644 (file)
@@ -1,5 +1,5 @@
 warning: item is named 'lintme'
-  --> $DIR/lint-group-plugin.rs:8:1
+  --> $DIR/lint-group-plugin.rs:9:1
    |
 LL | fn lintme() { } //~ WARNING item is named 'lintme'
    | ^^^^^^^^^^^^^^^
@@ -7,7 +7,7 @@ LL | fn lintme() { } //~ WARNING item is named 'lintme'
    = note: #[warn(test_lint)] on by default
 
 warning: item is named 'pleaselintme'
-  --> $DIR/lint-group-plugin.rs:9:1
+  --> $DIR/lint-group-plugin.rs:10:1
    |
 LL | fn pleaselintme() { } //~ WARNING item is named 'pleaselintme'
    | ^^^^^^^^^^^^^^^^^^^^^