diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-06-10 22:24:24 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-06-28 11:04:50 +0300 |
| commit | f0622dfe5d5414c59258d8c2669d26d3dc34a469 (patch) | |
| tree | b03f6d2decf23f587659df808a7dae472d55b59d | |
| parent | c6ca1e4abdb9476d8aa68457414ef80c5249caee (diff) | |
| download | rust-f0622dfe5d5414c59258d8c2669d26d3dc34a469.tar.gz rust-f0622dfe5d5414c59258d8c2669d26d3dc34a469.zip | |
Use `Ident`s for associated item definitions in HIR
Remove emulation of hygiene with gensyms
45 files changed, 176 insertions, 207 deletions
diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 61583d99894..f792a24503a 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -57,7 +57,7 @@ pub enum FnKind<'a> { ItemFn(Name, &'a Generics, FnHeader, &'a Visibility, &'a [Attribute]), /// fn foo(&self) - Method(Name, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]), + Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a [Attribute]), /// |x, y| {} Closure(&'a [Attribute]), @@ -823,7 +823,7 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V, } pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v TraitItem) { - visitor.visit_name(trait_item.span, trait_item.name); + visitor.visit_ident(trait_item.ident); walk_list!(visitor, visit_attribute, &trait_item.attrs); visitor.visit_generics(&trait_item.generics); match trait_item.node { @@ -840,7 +840,7 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai } } TraitItemKind::Method(ref sig, TraitMethod::Provided(body_id)) => { - visitor.visit_fn(FnKind::Method(trait_item.name, + visitor.visit_fn(FnKind::Method(trait_item.ident, sig, None, &trait_item.attrs), @@ -859,9 +859,9 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(visitor: &mut V, trait_item: &'v Trai pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref: &'v TraitItemRef) { // NB: Deliberately force a compilation error if/when new fields are added. - let TraitItemRef { id, name, ref kind, span, ref defaultness } = *trait_item_ref; + let TraitItemRef { id, ident, ref kind, span: _, ref defaultness } = *trait_item_ref; visitor.visit_nested_trait_item(id); - visitor.visit_name(span, name); + visitor.visit_ident(ident); visitor.visit_associated_item_kind(kind); visitor.visit_defaultness(defaultness); } @@ -871,16 +871,16 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt let ImplItem { id: _, hir_id: _, - name, + ident, ref vis, ref defaultness, ref attrs, ref generics, ref node, - span + span: _, } = *impl_item; - visitor.visit_name(span, name); + visitor.visit_ident(ident); visitor.visit_vis(vis); visitor.visit_defaultness(defaultness); walk_list!(visitor, visit_attribute, attrs); @@ -892,7 +892,7 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt visitor.visit_nested_body(body); } ImplItemKind::Method(ref sig, body_id) => { - visitor.visit_fn(FnKind::Method(impl_item.name, + visitor.visit_fn(FnKind::Method(impl_item.ident, sig, Some(&impl_item.vis), &impl_item.attrs), @@ -910,9 +910,9 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt pub fn walk_impl_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, impl_item_ref: &'v ImplItemRef) { // NB: Deliberately force a compilation error if/when new fields are added. - let ImplItemRef { id, name, ref kind, span, ref vis, ref defaultness } = *impl_item_ref; + let ImplItemRef { id, ident, ref kind, span: _, ref vis, ref defaultness } = *impl_item_ref; visitor.visit_nested_impl_item(id); - visitor.visit_name(span, name); + visitor.visit_ident(ident); visitor.visit_associated_item_kind(kind); visitor.visit_vis(vis); visitor.visit_defaultness(defaultness); diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 49675f6dc08..96f247f90d1 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -52,7 +52,7 @@ use middle::cstore::CrateStore; use rustc_data_structures::indexed_vec::IndexVec; use session::Session; use util::common::FN_OUTPUT_NAME; -use util::nodemap::{DefIdMap, FxHashMap, NodeMap}; +use util::nodemap::{DefIdMap, NodeMap}; use std::collections::{BTreeMap, HashSet}; use std::fmt::Debug; @@ -85,7 +85,6 @@ pub struct LoweringContext<'a> { cstore: &'a CrateStore, resolver: &'a mut Resolver, - name_map: FxHashMap<Ident, Name>, /// The items being lowered are collected here. items: BTreeMap<NodeId, hir::Item>, @@ -210,7 +209,6 @@ pub fn lower_crate( sess, cstore, resolver, - name_map: FxHashMap(), items: BTreeMap::new(), trait_items: BTreeMap::new(), impl_items: BTreeMap::new(), @@ -957,16 +955,6 @@ impl<'a> LoweringContext<'a> { } } - fn lower_ident(&mut self, ident: Ident) -> Name { - let ident = ident.modern(); - if ident.span.ctxt() == SyntaxContext::empty() { - return ident.name; - } - *self.name_map - .entry(ident) - .or_insert_with(|| Symbol::from_ident(ident)) - } - fn lower_label(&mut self, label: Option<Label>) -> Option<hir::Label> { label.map(|label| hir::Label { ident: label.ident, @@ -2962,7 +2950,7 @@ impl<'a> LoweringContext<'a> { hir::TraitItem { id: node_id, hir_id, - name: self.lower_ident(i.ident), + ident: i.ident, attrs: self.lower_attrs(&i.attrs), generics, node, @@ -2988,7 +2976,7 @@ impl<'a> LoweringContext<'a> { }; hir::TraitItemRef { id: hir::TraitItemId { node_id: i.id }, - name: self.lower_ident(i.ident), + ident: i.ident, span: i.span, defaultness: self.lower_defaultness(Defaultness::Default, has_default), kind, @@ -3054,7 +3042,7 @@ impl<'a> LoweringContext<'a> { hir::ImplItem { id: node_id, hir_id, - name: self.lower_ident(i.ident), + ident: i.ident, attrs: self.lower_attrs(&i.attrs), generics, vis: self.lower_visibility(&i.vis, None), @@ -3069,7 +3057,7 @@ impl<'a> LoweringContext<'a> { fn lower_impl_item_ref(&mut self, i: &ImplItem) -> hir::ImplItemRef { hir::ImplItemRef { id: hir::ImplItemId { node_id: i.id }, - name: self.lower_ident(i.ident), + ident: i.ident, span: i.span, vis: self.lower_visibility(&i.vis, Some(i.id)), defaultness: self.lower_defaultness(i.defaultness, true /* [1] */), diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index f665ced3dbc..930db8b0ccc 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -25,7 +25,7 @@ use hir as ast; use hir::map::{self, Node}; use hir::{Expr, FnDecl}; use hir::intravisit::FnKind; -use syntax::ast::{Attribute, Name, NodeId}; +use syntax::ast::{Attribute, Ident, Name, NodeId}; use syntax_pos::Span; /// An FnLikeNode is a Node that is like a fn, in that it has a decl @@ -209,8 +209,8 @@ impl<'a> FnLikeNode<'a> { let closure = |c: ClosureParts<'a>| { FnKind::Closure(c.attrs) }; - let method = |_, name: Name, sig: &'a ast::MethodSig, vis, _, _, attrs| { - FnKind::Method(name, sig, vis, attrs) + let method = |_, ident: Ident, sig: &'a ast::MethodSig, vis, _, _, attrs| { + FnKind::Method(ident, sig, vis, attrs) }; self.handle(item, method, closure) } @@ -218,7 +218,7 @@ impl<'a> FnLikeNode<'a> { fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where I: FnOnce(ItemFnParts<'a>) -> A, M: FnOnce(NodeId, - Name, + Ident, &'a ast::MethodSig, Option<&'a ast::Visibility>, ast::BodyId, @@ -245,14 +245,14 @@ impl<'a> FnLikeNode<'a> { }, map::NodeTraitItem(ti) => match ti.node { ast::TraitItemKind::Method(ref sig, ast::TraitMethod::Provided(body)) => { - method(ti.id, ti.name, sig, None, body, ti.span, &ti.attrs) + method(ti.id, ti.ident, sig, None, body, ti.span, &ti.attrs) } _ => bug!("trait method FnLikeNode that is not fn-like"), }, map::NodeImplItem(ii) => { match ii.node { ast::ImplItemKind::Method(ref sig, body) => { - method(ii.id, ii.name, sig, Some(&ii.vis), body, ii.span, &ii.attrs) + method(ii.id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs) } _ => { bug!("impl method FnLikeNode that is not fn-like") diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 14cecba490d..2d3e9804835 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -495,7 +495,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { // map the actual nodes, not the duplicate ones in the *Ref. let TraitItemRef { id, - name: _, + ident: _, kind: _, span: _, defaultness: _, @@ -509,7 +509,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> { // map the actual nodes, not the duplicate ones in the *Ref. let ImplItemRef { id, - name: _, + ident: _, kind: _, span: _, vis: _, diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index 2c21d15f7ec..5f390f20aca 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -949,8 +949,8 @@ impl<'hir> Map<'hir> { match self.get(id) { NodeItem(i) => i.name, NodeForeignItem(i) => i.name, - NodeImplItem(ii) => ii.name, - NodeTraitItem(ti) => ti.name, + NodeImplItem(ii) => ii.ident.name, + NodeTraitItem(ti) => ti.ident.name, NodeVariant(v) => v.node.name, NodeField(f) => f.ident.name, NodeLifetime(lt) => lt.name.ident().name, @@ -1149,8 +1149,8 @@ impl Named for Item { fn name(&self) -> Name { self.name } } impl Named for ForeignItem { fn name(&self) -> Name { self.name } } impl Named for Variant_ { fn name(&self) -> Name { self.name } } impl Named for StructField { fn name(&self) -> Name { self.ident.name } } -impl Named for TraitItem { fn name(&self) -> Name { self.name } } -impl Named for ImplItem { fn name(&self) -> Name { self.name } } +impl Named for TraitItem { fn name(&self) -> Name { self.ident.name } } +impl Named for ImplItem { fn name(&self) -> Name { self.ident.name } } pub fn map_crate<'hir>(sess: &::session::Session, @@ -1309,13 +1309,13 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { Some(NodeImplItem(ii)) => { match ii.node { ImplItemKind::Const(..) => { - format!("assoc const {} in {}{}", ii.name, path_str(), id_str) + format!("assoc const {} in {}{}", ii.ident, path_str(), id_str) } ImplItemKind::Method(..) => { - format!("method {} in {}{}", ii.name, path_str(), id_str) + format!("method {} in {}{}", ii.ident, path_str(), id_str) } ImplItemKind::Type(_) => { - format!("assoc type {} in {}{}", ii.name, path_str(), id_str) + format!("assoc type {} in {}{}", ii.ident, path_str(), id_str) } } } @@ -1326,7 +1326,7 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { TraitItemKind::Type(..) => "assoc type", }; - format!("{} {} in {}{}", kind, ti.name, path_str(), id_str) + format!("{} {} in {}{}", kind, ti.ident, path_str(), id_str) } Some(NodeVariant(ref variant)) => { format!("variant {} in {}{}", diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 47150d3d2c5..e46c0ba6f11 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1536,7 +1536,7 @@ pub struct TraitItemId { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct TraitItem { pub id: NodeId, - pub name: Name, + pub ident: Ident, pub hir_id: HirId, pub attrs: HirVec<Attribute>, pub generics: Generics, @@ -1579,7 +1579,7 @@ pub struct ImplItemId { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct ImplItem { pub id: NodeId, - pub name: Name, + pub ident: Ident, pub hir_id: HirId, pub vis: Visibility, pub defaultness: Defaultness, @@ -2140,7 +2140,7 @@ impl Item_ { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct TraitItemRef { pub id: TraitItemId, - pub name: Name, + pub ident: Ident, pub kind: AssociatedItemKind, pub span: Span, pub defaultness: Defaultness, @@ -2155,7 +2155,7 @@ pub struct TraitItemRef { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct ImplItemRef { pub id: ImplItemId, - pub name: Name, + pub ident: Ident, pub kind: AssociatedItemKind, pub span: Span, pub vis: Visibility, diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 81f10b1be7f..40dc9d04f21 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -497,14 +497,14 @@ impl<'a> State<'a> { } fn print_associated_const(&mut self, - name: ast::Name, + ident: ast::Ident, ty: &hir::Ty, default: Option<hir::BodyId>, vis: &hir::Visibility) -> io::Result<()> { self.s.word(&visibility_qualified(vis, ""))?; self.word_space("const")?; - self.print_name(name)?; + self.print_ident(ident)?; self.word_space(":")?; self.print_type(ty)?; if let Some(expr) = default { @@ -516,12 +516,12 @@ impl<'a> State<'a> { } fn print_associated_type(&mut self, - name: ast::Name, + ident: ast::Ident, bounds: Option<&hir::GenericBounds>, ty: Option<&hir::Ty>) -> io::Result<()> { self.word_space("type")?; - self.print_name(name)?; + self.print_ident(ident)?; if let Some(bounds) = bounds { self.print_bounds(":", bounds)?; } @@ -929,7 +929,7 @@ impl<'a> State<'a> { Ok(()) } pub fn print_method_sig(&mut self, - name: ast::Name, + ident: ast::Ident, m: &hir::MethodSig, generics: &hir::Generics, vis: &hir::Visibility, @@ -938,7 +938,7 @@ impl<'a> State<'a> { -> io::Result<()> { self.print_fn(&m.decl, m.header, - Some(name), + Some(ident.name), generics, vis, arg_names, @@ -952,16 +952,16 @@ impl<'a> State<'a> { self.print_outer_attributes(&ti.attrs)?; match ti.node { hir::TraitItemKind::Const(ref ty, default) => { - self.print_associated_const(ti.name, &ty, default, &hir::Inherited)?; + self.print_associated_const(ti.ident, &ty, default, &hir::Inherited)?; } hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Required(ref arg_names)) => { - self.print_method_sig(ti.name, sig, &ti.generics, &hir::Inherited, arg_names, + self.print_method_sig(ti.ident, sig, &ti.generics, &hir::Inherited, arg_names, None)?; self.s.word(";")?; } hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => { self.head("")?; - self.print_method_sig(ti.name, sig, &ti.generics, &hir::Inherited, &[], + self.print_method_sig(ti.ident, sig, &ti.generics, &hir::Inherited, &[], Some(body))?; self.nbsp()?; self.end()?; // need to close a box @@ -969,7 +969,7 @@ impl<'a> State<'a> { self.ann.nested(self, Nested::Body(body))?; } hir::TraitItemKind::Type(ref bounds, ref default) => { - self.print_associated_type(ti.name, + self.print_associated_type(ti.ident, Some(bounds), default.as_ref().map(|ty| &**ty))?; } @@ -986,18 +986,18 @@ impl<'a> State<'a> { match ii.node { hir::ImplItemKind::Const(ref ty, expr) => { - self.print_associated_const(ii.name, &ty, Some(expr), &ii.vis)?; + self.print_associated_const(ii.ident, &ty, Some(expr), &ii.vis)?; } hir::ImplItemKind::Method(ref sig, body) => { self.head("")?; - self.print_method_sig(ii.name, sig, &ii.generics, &ii.vis, &[], Some(body))?; + self.print_method_sig(ii.ident, sig, &ii.generics, &ii.vis, &[], Some(body))?; self.nbsp()?; self.end()?; // need to close a box self.end()?; // need to close a box self.ann.nested(self, Nested::Body(body))?; } hir::ImplItemKind::Type(ref ty) => { - self.print_associated_type(ii.name, None, Some(ty))?; + self.print_associated_type(ii.ident, None, Some(ty))?; } } self.ann.post(self, NodeSubItem(ii.id)) @@ -1615,7 +1615,7 @@ impl<'a> State<'a> { } pub fn print_name(&mut self, name: ast::Name) -> io::Result<()> { - self.print_ident(name.to_ident()) + self.print_ident(ast::Ident::with_empty_ctxt(name)) } pub fn print_for_decl(&mut self, loc: &hir::Local, coll: &hir::Expr) -> io::Result<()> { diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 94fda3e2874..9ab3acdce5e 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -705,7 +705,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem { let hir::TraitItem { id: _, hir_id: _, - name, + ident, ref attrs, ref generics, ref node, @@ -713,7 +713,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitItem { } = *self; hcx.hash_hir_item_like(|hcx| { - name.hash_stable(hcx, hasher); + ident.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher); generics.hash_stable(hcx, hasher); node.hash_stable(hcx, hasher); @@ -740,7 +740,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem { let hir::ImplItem { id: _, hir_id: _, - name, + ident, ref vis, defaultness, ref attrs, @@ -750,7 +750,7 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::ImplItem { } = *self; hcx.hash_hir_item_like(|hcx| { - name.hash_stable(hcx, hasher); + ident.hash_stable(hcx, hasher); vis.hash_stable(hcx, hasher); defaultness.hash_stable(hcx, hasher); attrs.hash_stable(hcx, hasher); @@ -916,7 +916,7 @@ impl_stable_hash_for!(enum hir::Item_ { impl_stable_hash_for!(struct hir::TraitItemRef { id, - name, + ident, kind, span, defaultness @@ -924,7 +924,7 @@ impl_stable_hash_for!(struct hir::TraitItemRef { impl_stable_hash_for!(struct hir::ImplItemRef { id, - name, + ident, kind, span, vis, diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 684a1d29658..e4214926b4c 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -1133,7 +1133,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::CratePredicatesMap<' impl_stable_hash_for!(struct ty::AssociatedItem { def_id, - name, + ident, kind, vis, defaultness, diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 4d6f2fb41b0..482af9c005f 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -1255,7 +1255,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { infer::LateBoundRegion(_, br, infer::AssocTypeProjection(def_id)) => format!( " for lifetime parameter {}in trait containing associated type `{}`", br_string(br), - self.tcx.associated_item(def_id).name + self.tcx.associated_item(def_id).ident ), infer::EarlyBoundRegion(_, name) => format!(" for lifetime parameter `{}`", name), infer::BoundRegionInCoherence(name) => { diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 7ebc0d4a4de..caf73096ebf 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -599,7 +599,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { if !self.symbol_is_live(impl_item.id, None) { self.warn_dead_code(impl_item.id, impl_item.span, - impl_item.name, + impl_item.ident.name, "associated const", "used"); } @@ -608,7 +608,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DeadVisitor<'a, 'tcx> { hir::ImplItemKind::Method(_, body_id) => { if !self.symbol_is_live(impl_item.id, None) { let span = self.tcx.sess.codemap().def_span(impl_item.span); - self.warn_dead_code(impl_item.id, span, impl_item.name, "method", "used"); + self.warn_dead_code(impl_item.id, span, impl_item.ident.name, "method", "used"); } self.visit_nested_body(body_id) } diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 4cdc9fdddbf..a289a2c21ce 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -744,7 +744,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { for impl_item_ref in impl_item_refs { let impl_item = self.tcx.hir.impl_item(impl_item_ref.id); let trait_item_def_id = self.tcx.associated_items(trait_did) - .find(|item| item.name == impl_item.name).map(|item| item.def_id); + .find(|item| item.ident.name == impl_item.ident.name) + .map(|item| item.def_id); if let Some(def_id) = trait_item_def_id { // Pass `None` to skip deprecation warnings. self.tcx.check_stability(def_id, None, impl_item.span); diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index 85bd5853d18..fe2965146cb 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -130,7 +130,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { .filter(|item| item.kind == ty::AssociatedKind::Method) .filter_map(|item| { self.object_safety_violation_for_method(trait_def_id, &item) - .map(|code| ObjectSafetyViolation::Method(item.name, code)) + .map(|code| ObjectSafetyViolation::Method(item.ident.name, code)) }).filter(|violation| { if let ObjectSafetyViolation::Method(_, MethodViolationCode::WhereClauseReferencesSelf(span)) = violation { @@ -159,7 +159,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { violations.extend(self.associated_items(trait_def_id) .filter(|item| item.kind == ty::AssociatedKind::Const) - .map(|item| ObjectSafetyViolation::AssociatedConst(item.name))); + .map(|item| ObjectSafetyViolation::AssociatedConst(item.ident.name))); debug!("object_safety_violations_for_trait(trait_def_id={:?}) = {:?}", trait_def_id, diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 77077732dcf..97b15048b48 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -32,7 +32,6 @@ use middle::const_val::ConstVal; use mir::interpret::{GlobalId}; use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap}; use syntax::ast::Ident; -use syntax::symbol::Symbol; use ty::subst::{Subst, Substs}; use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt}; use ty::fold::{TypeFoldable, TypeFolder}; @@ -1350,10 +1349,10 @@ fn confirm_generator_candidate<'cx, 'gcx, 'tcx>( obligation.predicate.self_ty(), gen_sig) .map_bound(|(trait_ref, yield_ty, return_ty)| { - let name = tcx.associated_item(obligation.predicate.item_def_id).name; - let ty = if name == Symbol::intern("Return") { + let name = tcx.associated_item(obligation.predicate.item_def_id).ident.name; + let ty = if name == "Return" { return_ty - } else if name == Symbol::intern("Yield") { + } else if name == "Yield" { yield_ty } else { bug!() @@ -1509,7 +1508,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>( // checker method `check_impl_items_against_trait`, so here we // just return TyError. debug!("confirm_impl_candidate: no associated type {:?} for {:?}", - assoc_ty.item.name, + assoc_ty.item.ident, obligation.predicate); tcx.types.err } else { @@ -1534,7 +1533,7 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>( -> specialization_graph::NodeItem<ty::AssociatedItem> { let tcx = selcx.tcx(); - let assoc_ty_name = tcx.associated_item(assoc_ty_def_id).name; + let assoc_ty_name = tcx.associated_item(assoc_ty_def_id).ident; let trait_def_id = tcx.impl_trait_ref(impl_def_id).unwrap().def_id; let trait_def = tcx.trait_def(trait_def_id); @@ -1547,7 +1546,7 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>( let impl_node = specialization_graph::Node::Impl(impl_def_id); for item in impl_node.items(tcx) { if item.kind == ty::AssociatedKind::Type && - tcx.hygienic_eq(item.name.to_ident(), assoc_ty_name.to_ident(), trait_def_id) { + tcx.hygienic_eq(item.ident, assoc_ty_name, trait_def_id) { return specialization_graph::NodeItem { node: specialization_graph::Node::Impl(impl_def_id), item, diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index f6ae5113cb2..f151f3b2531 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -129,7 +129,7 @@ pub fn find_associated_item<'a, 'tcx>( let trait_def = tcx.trait_def(trait_def_id); let ancestors = trait_def.ancestors(tcx, impl_data.impl_def_id); - match ancestors.defs(tcx, item.name, item.kind, trait_def_id).next() { + match ancestors.defs(tcx, item.ident, item.kind, trait_def_id).next() { Some(node_item) => { let substs = tcx.infer_ctxt().enter(|infcx| { let param_env = ty::ParamEnv::reveal_all(); diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index 9b0edf42fdf..b64e4228be9 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -18,7 +18,7 @@ use traits; use ty::{self, TyCtxt, TypeFoldable}; use ty::fast_reject::{self, SimplifiedType}; use rustc_data_structures::sync::Lrc; -use syntax::ast::Name; +use syntax::ast::Ident; use util::captures::Captures; use util::nodemap::{DefIdMap, FxHashMap}; @@ -372,14 +372,14 @@ impl<'a, 'gcx, 'tcx> Ancestors { pub fn defs( self, tcx: TyCtxt<'a, 'gcx, 'tcx>, - trait_item_name: Name, + trait_item_name: Ident, trait_item_kind: ty::AssociatedKind, trait_def_id: DefId, ) -> impl Iterator<Item = NodeItem<ty::AssociatedItem>> + Captures<'gcx> + Captures<'tcx> + 'a { self.flat_map(move |node| { node.items(tcx).filter(move |impl_item| { impl_item.kind == trait_item_kind && - tcx.hygienic_eq(impl_item.name.to_ident(), trait_item_name.to_ident(), trait_def_id) + tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id) }).map(move |item| NodeItem { node: node, item: item }) }) } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 686c560fe84..d8fa978a6a0 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -177,7 +177,7 @@ pub struct ImplHeader<'tcx> { #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct AssociatedItem { pub def_id: DefId, - pub name: Name, + pub ident: Ident, pub kind: AssociatedKind, pub vis: Visibility, pub defaultness: hir::Defaultness, @@ -224,9 +224,9 @@ impl AssociatedItem { // regions just fine, showing `fn(&MyType)`. format!("{}", tcx.fn_sig(self.def_id).skip_binder()) } - ty::AssociatedKind::Type => format!("type {};", self.name.to_string()), + ty::AssociatedKind::Type => format!("type {};", self.ident), ty::AssociatedKind::Const => { - format!("const {}: {:?};", self.name.to_string(), tcx.type_of(self.def_id)) + format!("const {}: {:?};", self.ident, tcx.type_of(self.def_id)) } } } @@ -2494,7 +2494,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { }; AssociatedItem { - name: trait_item_ref.name, + ident: trait_item_ref.ident, kind, // Visibility of trait items is inherited from their traits. vis: Visibility::from_hir(parent_vis, trait_item_ref.id.node_id, self), @@ -2518,8 +2518,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { hir::AssociatedItemKind::Type => (ty::AssociatedKind::Type, false), }; - ty::AssociatedItem { - name: impl_item_ref.name, + AssociatedItem { + ident: impl_item_ref.ident, kind, // Visibility of trait impl items doesn't matter. vis: ty::Visibility::from_hir(&impl_item_ref.vis, impl_item_ref.id.node_id, self), @@ -2544,10 +2544,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn associated_items( self, def_id: DefId, - ) -> impl Iterator<Item = ty::AssociatedItem> + 'a { + ) -> impl Iterator<Item = AssociatedItem> + 'a { let def_ids = self.associated_item_def_ids(def_id); Box::new((0..def_ids.len()).map(move |i| self.associated_item(def_ids[i]))) - as Box<dyn Iterator<Item = ty::AssociatedItem> + 'a> + as Box<dyn Iterator<Item = AssociatedItem> + 'a> } /// Returns true if the impls are the same polarity and are implementing diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index a34e1e43009..186ebd73b4c 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -857,7 +857,7 @@ impl<'a, 'tcx> ProjectionTy<'tcx> { ) -> ProjectionTy<'tcx> { let item_def_id = tcx.associated_items(trait_ref.def_id).find(|item| { item.kind == ty::AssociatedKind::Type && - tcx.hygienic_eq(item_name, item.name.to_ident(), trait_ref.def_id) + tcx.hygienic_eq(item_name, item.ident, trait_ref.def_id) }).unwrap().def_id; ProjectionTy { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 4fe9c34c140..ff6d711cef0 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -429,7 +429,7 @@ impl PrintContext { ty::tls::with(|tcx| print!(f, self, write("{}=", - tcx.associated_item(projection.projection_ty.item_def_id).name), + tcx.associated_item(projection.projection_ty.item_def_id).ident), print_display(projection.ty)) )?; } @@ -1286,7 +1286,7 @@ define_print! { // parameterized(f, self.substs, self.item_def_id, &[]) // (which currently ICEs). let (trait_ref, item_name) = ty::tls::with(|tcx| - (self.trait_ref(tcx), tcx.associated_item(self.item_def_id).name) + (self.trait_ref(tcx), tcx.associated_item(self.item_def_id).ident) ); print!(f, cx, print_debug(trait_ref), write("::{}", item_name)) } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 67fd5da8c92..84f7b35d21f 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1075,7 +1075,7 @@ impl RustcDefaultCalls { let mut cfgs = Vec::new(); for &(name, ref value) in sess.parse_sess.config.iter() { let gated_cfg = GatedCfg::gate(&ast::MetaItem { - ident: ast::Path::from_ident(name.to_ident()), + ident: ast::Path::from_ident(ast::Ident::with_empty_ctxt(name)), node: ast::MetaItemKind::Word, span: DUMMY_SP, }); diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index af34530a548..6bc364b7261 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -305,7 +305,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase { if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(ref pnames)) = item.node { self.check_snake_case(cx, "trait method", - &item.name.as_str(), + &item.ident.as_str(), Some(item.span)); for param_name in pnames { self.check_snake_case(cx, "variable", ¶m_name.as_str(), Some(param_name.span)); @@ -385,7 +385,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals { fn check_trait_item(&mut self, cx: &LateContext, ti: &hir::TraitItem) { match ti.node { hir::TraitItemKind::Const(..) => { - NonUpperCaseGlobals::check_upper_case(cx, "associated constant", ti.name, ti.span); + NonUpperCaseGlobals::check_upper_case(cx, "associated constant", + ti.ident.name, ti.span); } _ => {} } @@ -394,7 +395,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals { fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) { match ii.node { hir::ImplItemKind::Const(..) => { - NonUpperCaseGlobals::check_upper_case(cx, "associated constant", ii.name, ii.span); + NonUpperCaseGlobals::check_upper_case(cx, "associated constant", + ii.ident.name, ii.span); } _ => {} } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index aa952c5330e..b4dc5f9c85b 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1078,7 +1078,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { let container = ty::ImplContainer(vtable_impl.impl_def_id); // It matches if it comes from the same impl, // and has the same method name. - container == method.container && callee_item.name == method.name + container == method.container && + callee_item.ident.name == method.ident.name } // There's no way to know if this call is diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 9e4f695d28f..6eea4b2617c 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -817,7 +817,7 @@ impl<'a, 'tcx> CrateMetadata { }; ty::AssociatedItem { - name: name.as_symbol(), + ident: Ident::from_interned_str(name), kind, vis: item.visibility.decode(self), defaultness: container.defaultness(), diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 8ff1738394e..167e031fbee 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -235,7 +235,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { let method_name = Symbol::intern(method_name); let substs = self.tcx.mk_substs_trait(self_ty, params); for item in self.tcx.associated_items(trait_def_id) { - if item.kind == ty::AssociatedKind::Method && item.name == method_name { + if item.kind == ty::AssociatedKind::Method && item.ident.name == method_name { let method_ty = self.tcx.type_of(item.def_id); let method_ty = method_ty.subst(self.tcx, substs); return (method_ty, diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index ef69cb574e0..c079b9d3dc4 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -1115,10 +1115,10 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) { let overridden_methods: FxHashSet<_> = impl_item_refs.iter() - .map(|iiref| iiref.name) + .map(|iiref| iiref.ident.modern()) .collect(); for method in tcx.provided_trait_methods(trait_ref.def_id) { - if overridden_methods.contains(&method.name) { + if overridden_methods.contains(&method.ident.modern()) { continue; } diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 27f8254bf8a..0428489fd8d 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -441,7 +441,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { for projection in projections { let projection = projection.skip_binder(); - let name = &self.tcx.associated_item(projection.item_def_id).name.as_str(); + let name = &self.tcx.associated_item(projection.item_def_id).ident.as_str(); output.push_str(name); output.push_str("="); self.push_type_name(projection.ty, output); diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 1437aa5fcc5..d3825ff4919 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3505,7 +3505,7 @@ impl<'a> Resolver<'a> { match path.get(1) { // If this import looks like `crate::...` it's already good - Some(name) if name.name == keywords::Crate.name() => return, + Some(ident) if ident.name == keywords::Crate.name() => return, // Otherwise go below to see if it's an extern crate Some(_) => {} // If the path has length one (and it's `CrateRoot` most likely) diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 262c0e40abc..311978ec248 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -316,14 +316,14 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { sig: &'l ast::MethodSig, body: Option<&'l ast::Block>, id: ast::NodeId, - name: ast::Ident, + ident: ast::Ident, generics: &'l ast::Generics, vis: ast::Visibility, span: Span, ) { - debug!("process_method: {}:{}", id, name); + debug!("process_method: {}:{}", id, ident); - if let Some(mut method_data) = self.save_ctxt.get_method_data(id, name.name, span) { + if let Some(mut method_data) = self.save_ctxt.get_method_data(id, ident.name, span) { let sig_str = ::make_signature(&sig.decl, &generics); if body.is_some() { self.nest_tables( @@ -335,7 +335,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { self.process_generic_params(&generics, span, &method_data.qualname, id); method_data.value = sig_str; - method_data.sig = sig::method_signature(id, name, generics, sig, &self.save_ctxt); + method_data.sig = sig::method_signature(id, ident, generics, sig, &self.save_ctxt); self.dumper.dump_def(&access_from!(self.save_ctxt, vis, id), method_data); } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index deb91774175..89d30fd666a 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -438,7 +438,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { qualname.push_str(&self.tcx.item_path_str(def_id)); self.tcx .associated_items(def_id) - .find(|item| item.name == name) + .find(|item| item.ident.name == name) .map(|item| decl_id = Some(item.def_id)); } qualname.push_str(">"); @@ -775,7 +775,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { let ti = self.tcx.associated_item(decl_id); self.tcx .associated_items(ti.container.id()) - .find(|item| item.name == ti.name && item.defaultness.has_value()) + .find(|item| item.ident.name == ti.ident.name && + item.defaultness.has_value()) .map(|item| item.def_id) } else { None diff --git a/src/librustc_traits/lowering.rs b/src/librustc_traits/lowering.rs index 137a6b5c78d..214376b2e53 100644 --- a/src/librustc_traits/lowering.rs +++ b/src/librustc_traits/lowering.rs @@ -417,7 +417,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>( let hypotheses = vec![trait_implemented]; // `<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm>` - let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.name.to_ident()); + let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.ident); // `Normalize(<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm> -> T)` let normalize_goal = DomainGoal::Normalize(ty::ProjectionPredicate { projection_ty, ty }); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 1954d81d328..762dc5d26f5 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -490,7 +490,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { { self.tcx().associated_items(trait_def_id).any(|item| { item.kind == ty::AssociatedKind::Type && - self.tcx().hygienic_eq(assoc_name, item.name.to_ident(), trait_def_id) + self.tcx().hygienic_eq(assoc_name, item.ident, trait_def_id) }) } @@ -571,7 +571,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { let (assoc_ident, def_scope) = tcx.adjust_ident(binding.item_name, candidate.def_id(), ref_id); let assoc_ty = tcx.associated_items(candidate.def_id()).find(|i| { - i.kind == ty::AssociatedKind::Type && i.name.to_ident() == assoc_ident + i.kind == ty::AssociatedKind::Type && i.ident.modern() == assoc_ident }).expect("missing associated type"); if !assoc_ty.vis.is_accessible_from(def_scope, tcx) { @@ -711,10 +711,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { let trait_def_id = assoc_item.container.id(); struct_span_err!(tcx.sess, span, E0191, "the value of the associated type `{}` (from the trait `{}`) must be specified", - assoc_item.name, + assoc_item.ident, tcx.item_path_str(trait_def_id)) .span_label(span, format!( - "missing associated type `{}` value", assoc_item.name)) + "missing associated type `{}` value", assoc_item.ident)) .emit(); } @@ -837,7 +837,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { for bound in bounds { let bound_span = self.tcx().associated_items(bound.def_id()).find(|item| { item.kind == ty::AssociatedKind::Type && - self.tcx().hygienic_eq(assoc_name, item.name.to_ident(), bound.def_id()) + self.tcx().hygienic_eq(assoc_name, item.ident, bound.def_id()) }) .and_then(|item| self.tcx().hir.span_if_local(item.def_id)); @@ -925,7 +925,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { let (assoc_ident, def_scope) = tcx.adjust_ident(assoc_name, trait_did, ref_id); let item = tcx.associated_items(trait_did).find(|i| { Namespace::from(i.kind) == Namespace::Type && - i.name.to_ident() == assoc_ident + i.ident.modern() == assoc_ident }) .expect("missing associated type"); diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index b0f9a4c8b85..383820a62bf 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -18,7 +18,7 @@ use rustc::{infer, traits}; use rustc::ty::{self, TyCtxt, TypeFoldable, Ty}; use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc_target::spec::abi; -use syntax::symbol::Symbol; +use syntax::ast::Ident; use syntax_pos::Span; use rustc::hir; @@ -157,9 +157,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { MethodCallee<'tcx>)> { // Try the options that are least restrictive on the caller first. for &(opt_trait_def_id, method_name, borrow) in - &[(self.tcx.lang_items().fn_trait(), Symbol::intern("call"), true), - (self.tcx.lang_items().fn_mut_trait(), Symbol::intern("call_mut"), true), - (self.tcx.lang_items().fn_once_trait(), Symbol::intern("call_once"), false)] { + &[(self.tcx.lang_items().fn_trait(), Ident::from_str("call"), true), + (self.tcx.lang_items().fn_mut_trait(), Ident::from_str("call_mut"), true), + (self.tcx.lang_items().fn_once_trait(), Ident::from_str("call_once"), false)] { let trait_def_id = match opt_trait_def_id { Some(def_id) => def_id, None => continue, diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 5f8955612e1..04c11d30d26 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -100,7 +100,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: impl_m_span, body_id: impl_m_node_id, code: ObligationCauseCode::CompareImplMethodObligation { - item_name: impl_m.name, + item_name: impl_m.ident.name, impl_item_def_id: impl_m.def_id, trait_item_def_id: trait_m.def_id, }, @@ -318,7 +318,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cause.span(&tcx), E0053, "method `{}` has an incompatible type for trait", - trait_m.name); + trait_m.ident); infcx.note_type_err(&mut diag, &cause, @@ -383,7 +383,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, E0195, "lifetime parameters or bounds on method `{}` do not match \ the trait declaration", - impl_m.name); + impl_m.ident); err.span_label(span, "lifetimes do not match method in trait"); if let Some(sp) = tcx.hir.span_if_local(trait_m.def_id) { err.span_label(tcx.sess.codemap().def_span(sp), @@ -529,13 +529,13 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, E0185, "method `{}` has a `{}` declaration in the impl, but \ not in the trait", - trait_m.name, + trait_m.ident, self_descr); err.span_label(impl_m_span, format!("`{}` used in impl", self_descr)); if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) { err.span_label(span, format!("trait method declared without `{}`", self_descr)); } else { - err.note_trait_signature(trait_m.name.to_string(), + err.note_trait_signature(trait_m.ident.to_string(), trait_m.signature(&tcx)); } err.emit(); @@ -549,13 +549,13 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, E0186, "method `{}` has a `{}` declaration in the trait, but \ not in the impl", - trait_m.name, + trait_m.ident, self_descr); err.span_label(impl_m_span, format!("expected `{}` in impl", self_descr)); if let Some(span) = tcx.hir.span_if_local(trait_m.def_id) { err.span_label(span, format!("`{}` used in trait", self_descr)); } else { - err.note_trait_signature(trait_m.name.to_string(), + err.note_trait_signature(trait_m.ident.to_string(), trait_m.signature(&tcx)); } err.emit(); @@ -590,7 +590,7 @@ fn compare_number_of_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, E0049, "method `{}` has {} type parameter{} but its trait \ declaration has {} type parameter{}", - trait_m.name, + trait_m.ident, num_impl_m_type_params, if num_impl_m_type_params == 1 { "" } else { "s" }, num_trait_m_type_params, @@ -681,7 +681,7 @@ fn compare_number_of_method_arguments<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, E0050, "method `{}` has {} parameter{} but the declaration in \ trait `{}` has {}", - trait_m.name, + trait_m.ident, impl_number_args, if impl_number_args == 1 { "" } else { "s" }, tcx.item_path_str(trait_m.def_id), @@ -695,7 +695,7 @@ fn compare_number_of_method_arguments<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, format!("{} parameter", trait_number_args) })); } else { - err.note_trait_signature(trait_m.name.to_string(), + err.note_trait_signature(trait_m.ident.to_string(), trait_m.signature(&tcx)); } err.span_label(impl_span, @@ -748,7 +748,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_span, E0643, "method `{}` has incompatible signature for trait", - trait_m.name); + trait_m.ident); err.span_label(trait_span, "declaration in trait here"); match (impl_synthetic, trait_synthetic) { // The case where the impl method uses `impl Trait` but the trait method uses @@ -948,7 +948,7 @@ pub fn compare_const_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, E0326, "implemented const `{}` has an incompatible type for \ trait", - trait_c.name); + trait_c.ident); let trait_c_node_id = tcx.hir.as_local_node_id(trait_c.def_id); let trait_c_span = trait_c_node_id.map(|trait_c_node_id| { diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 2b619781119..8582eb3fbd8 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -146,7 +146,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let methods = self.get_conversion_methods(expr.span, expected, checked_ty); if let Ok(expr_text) = self.tcx.sess.codemap().span_to_snippet(expr.span) { let suggestions = iter::repeat(expr_text).zip(methods.iter()) - .map(|(receiver, method)| format!("{}.{}()", receiver, method.name)) + .map(|(receiver, method)| format!("{}.{}()", receiver, method.ident)) .collect::<Vec<_>>(); if !suggestions.is_empty() { err.span_suggestions(expr.span, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index e160ceec1ee..04c32fa8827 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -244,7 +244,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// of this method is basically the same as confirmation. pub fn lookup_method_in_trait(&self, span: Span, - m_name: ast::Name, + m_name: ast::Ident, trait_def_id: DefId, self_ty: Ty<'tcx>, opt_input_types: Option<&[Ty<'tcx>]>) @@ -290,7 +290,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // type parameters or early-bound regions. let tcx = self.tcx; let method_item = - self.associated_item(trait_def_id, m_name.to_ident(), Namespace::Value).unwrap(); + self.associated_item(trait_def_id, m_name, Namespace::Value).unwrap(); let def_id = method_item.def_id; let generics = tcx.generics_of(def_id); assert_eq!(generics.params.len(), 0); @@ -390,7 +390,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { -> Option<ty::AssociatedItem> { self.tcx.associated_items(def_id).find(|item| { Namespace::from(item.kind) == ns && - self.tcx.hygienic_eq(item_name, item.name.to_ident(), def_id) + self.tcx.hygienic_eq(item_name, item.ident, def_id) }) } } diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index ccbc0f9cfe2..0aff322a29a 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -810,7 +810,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { true } }) - .map(|candidate| candidate.item.name.to_ident()) + .map(|candidate| candidate.item.ident) .filter(|&name| set.insert(name)) .collect(); @@ -1309,14 +1309,14 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { Ok(None) } else { let best_name = { - let names = applicable_close_candidates.iter().map(|cand| &cand.name); + let names = applicable_close_candidates.iter().map(|cand| &cand.ident.name); find_best_match_for_name(names, &self.method_name.unwrap().as_str(), None) }.unwrap(); Ok(applicable_close_candidates .into_iter() - .find(|method| method.name == best_name)) + .find(|method| method.ident.name == best_name)) } }) } @@ -1456,7 +1456,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { let max_dist = max(name.as_str().len(), 3) / 3; self.tcx.associated_items(def_id) .filter(|x| { - let dist = lev_distance(&*name.as_str(), &x.name.as_str()); + let dist = lev_distance(&*name.as_str(), &x.ident.as_str()); Namespace::from(x.kind) == Namespace::Value && dist > 0 && dist <= max_dist }) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index f6c66a9a14a..35d237d94de 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -444,7 +444,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } if let Some(lev_candidate) = lev_candidate { - err.help(&format!("did you mean `{}`?", lev_candidate.name)); + err.help(&format!("did you mean `{}`?", lev_candidate.ident)); } err.emit(); } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 1c107e1cdca..f42366e5dbe 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1333,15 +1333,15 @@ fn report_forbidden_specialization<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx.sess, impl_item.span, E0520, "`{}` specializes an item from a parent `impl`, but \ that item is not marked `default`", - impl_item.name); + impl_item.ident); err.span_label(impl_item.span, format!("cannot specialize default item `{}`", - impl_item.name)); + impl_item.ident)); match tcx.span_of_impl(parent_impl) { Ok(span) => { err.span_label(span, "parent `impl` is here"); err.note(&format!("to specialize, `{}` in the parent `impl` must be marked `default`", - impl_item.name)); + impl_item.ident)); } Err(cname) => { err.note(&format!("parent implementation is in crate `{}`", cname)); @@ -1365,7 +1365,7 @@ fn check_specialization_validity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir::ImplItemKind::Type(_) => ty::AssociatedKind::Type }; - let parent = ancestors.defs(tcx, trait_item.name, kind, trait_def.def_id).skip(1).next() + let parent = ancestors.defs(tcx, trait_item.ident, kind, trait_def.def_id).skip(1).next() .map(|node_item| node_item.map(|parent| parent.defaultness)); if let Some(parent) = parent { @@ -1400,13 +1400,11 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let ty_impl_item = tcx.associated_item(tcx.hir.local_def_id(impl_item.id)); let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id) .find(|ac| Namespace::from(&impl_item.node) == Namespace::from(ac.kind) && - tcx.hygienic_eq(ty_impl_item.name.to_ident(), ac.name.to_ident(), - impl_trait_ref.def_id)) + tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id)) .or_else(|| { // Not compatible, but needed for the error message tcx.associated_items(impl_trait_ref.def_id) - .find(|ac| tcx.hygienic_eq(ty_impl_item.name.to_ident(), ac.name.to_ident(), - impl_trait_ref.def_id)) + .find(|ac| tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id)) }); // Check that impl definition matches trait definition @@ -1424,7 +1422,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut err = struct_span_err!(tcx.sess, impl_item.span, E0323, "item `{}` is an associated const, \ which doesn't match its trait `{}`", - ty_impl_item.name, + ty_impl_item.ident, impl_trait_ref); err.span_label(impl_item.span, "does not match trait"); // We can only get the spans from local trait definition @@ -1448,7 +1446,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324, "item `{}` is an associated method, \ which doesn't match its trait `{}`", - ty_impl_item.name, + ty_impl_item.ident, impl_trait_ref); err.span_label(impl_item.span, "does not match trait"); if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) { @@ -1466,7 +1464,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut err = struct_span_err!(tcx.sess, impl_item.span, E0325, "item `{}` is an associated type, \ which doesn't match its trait `{}`", - ty_impl_item.name, + ty_impl_item.ident, impl_trait_ref); err.span_label(impl_item.span, "does not match trait"); if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) { @@ -1487,7 +1485,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let associated_type_overridden = overridden_associated_type.is_some(); for trait_item in tcx.associated_items(impl_trait_ref.def_id) { let is_implemented = trait_def.ancestors(tcx, impl_id) - .defs(tcx, trait_item.name, trait_item.kind, impl_trait_ref.def_id) + .defs(tcx, trait_item.ident, trait_item.kind, impl_trait_ref.def_id) .next() .map(|node_item| !node_item.node.is_from_trait()) .unwrap_or(false); @@ -1496,7 +1494,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if !trait_item.defaultness.has_value() { missing_items.push(trait_item); } else if associated_type_overridden { - invalidated_items.push(trait_item.name); + invalidated_items.push(trait_item.ident); } } } @@ -1505,17 +1503,17 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut err = struct_span_err!(tcx.sess, impl_span, E0046, "not all trait items implemented, missing: `{}`", missing_items.iter() - .map(|trait_item| trait_item.name.to_string()) + .map(|trait_item| trait_item.ident.to_string()) .collect::<Vec<_>>().join("`, `")); err.span_label(impl_span, format!("missing `{}` in implementation", missing_items.iter() - .map(|trait_item| trait_item.name.to_string()) + .map(|trait_item| trait_item.ident.to_string()) .collect::<Vec<_>>().join("`, `"))); for trait_item in missing_items { if let Some(span) = tcx.hir.span_if_local(trait_item.def_id) { - err.span_label(span, format!("`{}` from trait", trait_item.name)); + err.span_label(span, format!("`{}` from trait", trait_item.ident)); } else { - err.note_trait_signature(trait_item.name.to_string(), + err.note_trait_signature(trait_item.ident.to_string(), trait_item.signature(&tcx)); } } @@ -1527,7 +1525,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span_err!(tcx.sess, invalidator.span, E0399, "the following trait items need to be reimplemented \ as `{}` was overridden: `{}`", - invalidator.name, + invalidator.ident, invalidated_items.iter() .map(|name| name.to_string()) .collect::<Vec<_>>().join("`, `")) @@ -2470,7 +2468,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None } - fn resolve_place_op(&self, op: PlaceOp, is_mut: bool) -> (Option<DefId>, Symbol) { + fn resolve_place_op(&self, op: PlaceOp, is_mut: bool) -> (Option<DefId>, ast::Ident) { let (tr, name) = match (op, is_mut) { (PlaceOp::Deref, false) => (self.tcx.lang_items().deref_trait(), "deref"), @@ -2481,7 +2479,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { (PlaceOp::Index, true) => (self.tcx.lang_items().index_mut_trait(), "index_mut"), }; - (tr, Symbol::intern(name)) + (tr, ast::Ident::from_str(name)) } fn try_overloaded_place_op(&self, diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 2dd22058d76..0a33252d4cd 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -18,7 +18,7 @@ use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoB use rustc::infer::type_variable::TypeVariableOrigin; use errors; use syntax_pos::Span; -use syntax::symbol::Symbol; +use syntax::ast::Ident; use rustc::hir; impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { @@ -564,7 +564,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { trait_did); let method = trait_did.and_then(|trait_did| { - let opname = Symbol::intern(opname); + let opname = Ident::from_str(opname); self.lookup_method_in_trait(span, opname, trait_did, lhs_ty, Some(other_tys)) }); diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 88a2dc817ae..6a346b02b79 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -35,7 +35,7 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> { let name_and_namespace = |def_id| { let item = self.tcx.associated_item(def_id); - (item.name, Namespace::from(item.kind)) + (item.ident, Namespace::from(item.kind)) }; let impl_items1 = self.tcx.associated_item_def_ids(impl1); diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 7b7cb254979..b57bb1fccfb 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -184,14 +184,14 @@ fn enforce_impl_items_are_distinct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir::ImplItemKind::Type(_) => &mut seen_type_items, _ => &mut seen_value_items, }; - match seen_items.entry(impl_item.name) { + match seen_items.entry(impl_item.ident.modern()) { Occupied(entry) => { let mut err = struct_span_err!(tcx.sess, impl_item.span, E0201, "duplicate definitions with name `{}`:", - impl_item.name); + impl_item.ident); err.span_label(*entry.get(), format!("previous definition of `{}` here", - impl_item.name)); + impl_item.ident)); err.span_label(impl_item.span, "duplicate definition"); err.emit(); } diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index ad7389db729..7677ccf8bf4 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -391,7 +391,7 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) { let provided = trait_.def_id().map(|did| { tcx.provided_trait_methods(did) .into_iter() - .map(|meth| meth.name.to_string()) + .map(|meth| meth.ident.to_string()) .collect() }).unwrap_or(FxHashSet()); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index f63084b3f19..c4729ce67d8 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1146,7 +1146,7 @@ fn resolve(cx: &DocContext, path_str: &str, is_val: bool) -> Result<(Def, Option Def::Struct(did) | Def::Union(did) | Def::Enum(did) | Def::TyAlias(did) => { let item = cx.tcx.inherent_impls(did).iter() .flat_map(|imp| cx.tcx.associated_items(*imp)) - .find(|item| item.name == item_name); + .find(|item| item.ident.name == item_name); if let Some(item) = item { let out = match item.kind { ty::AssociatedKind::Method if is_val => "method", @@ -1181,7 +1181,7 @@ fn resolve(cx: &DocContext, path_str: &str, is_val: bool) -> Result<(Def, Option Def::Trait(did) => { let item = cx.tcx.associated_item_def_ids(did).iter() .map(|item| cx.tcx.associated_item(*item)) - .find(|item| item.name == item_name); + .find(|item| item.ident.name == item_name); if let Some(item) = item { let kind = match item.kind { ty::AssociatedKind::Const if is_val => "associatedconstant", @@ -1823,7 +1823,7 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> { GenericBound::Outlives(_) => panic!("cleaning a trait got a lifetime"), }; Type::QPath { - name: cx.tcx.associated_item(self.item_def_id).name.clean(cx), + name: cx.tcx.associated_item(self.item_def_id).ident.name.clean(cx), self_type: box self.self_ty().clean(cx), trait_: box trait_ } @@ -2360,7 +2360,7 @@ impl Clean<Item> for hir::TraitItem { } }; Item { - name: Some(self.name.clean(cx)), + name: Some(self.ident.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.span.clean(cx), def_id: cx.tcx.hir.local_def_id(self.id), @@ -2388,7 +2388,7 @@ impl Clean<Item> for hir::ImplItem { }, true), }; Item { - name: Some(self.name.clean(cx)), + name: Some(self.ident.name.clean(cx)), source: self.span.clean(cx), attrs: self.attrs.clean(cx), def_id: cx.tcx.hir.local_def_id(self.id), @@ -2474,7 +2474,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem { } } ty::AssociatedKind::Type => { - let my_name = self.name.clean(cx); + let my_name = self.ident.name.clean(cx); if let ty::TraitContainer(did) = self.container { // When loading a cross-crate associated type, the bounds for this type @@ -2537,7 +2537,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem { }; Item { - name: Some(self.name.clean(cx)), + name: Some(self.ident.name.clean(cx)), visibility, stability: get_stability(cx, self.def_id), deprecation: get_deprecation(cx, self.def_id), @@ -3099,7 +3099,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> { let mut bindings = vec![]; for pb in obj.projection_bounds() { bindings.push(TypeBinding { - name: cx.tcx.associated_item(pb.item_def_id()).name.clean(cx), + name: cx.tcx.associated_item(pb.item_def_id()).ident.name.clean(cx), ty: pb.skip_binder().ty.clean(cx) }); } @@ -3156,7 +3156,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> { if proj.projection_ty.trait_ref(cx.tcx) == *trait_ref.skip_binder() { Some(TypeBinding { name: cx.tcx.associated_item(proj.projection_ty.item_def_id) - .name.clean(cx), + .ident.name.clean(cx), ty: proj.ty.clean(cx), }) } else { @@ -3823,7 +3823,7 @@ impl Clean<Vec<Item>> for doctree::Impl { let provided = trait_.def_id().map(|did| { cx.tcx.provided_trait_methods(did) .into_iter() - .map(|meth| meth.name.to_string()) + .map(|meth| meth.ident.to_string()) .collect() }).unwrap_or(FxHashSet()); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index fe992169ca9..53032b9b98c 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -718,13 +718,13 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirCollector<'a, 'hir> { } fn visit_trait_item(&mut self, item: &'hir hir::TraitItem) { - self.visit_testable(item.name.to_string(), &item.attrs, |this| { + self.visit_testable(item.ident.to_string(), &item.attrs, |this| { intravisit::walk_trait_item(this, item); }); } fn visit_impl_item(&mut self, item: &'hir hir::ImplItem) { - self.visit_testable(item.name.to_string(), &item.attrs, |this| { + self.visit_testable(item.ident.to_string(), &item.attrs, |this| { intravisit::walk_impl_item(this, item); }); } diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index d1b9c7a84d1..99d8b1b172d 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -18,7 +18,7 @@ use GLOBALS; use Span; use edition::Edition; -use symbol::{Ident, Symbol}; +use symbol::Symbol; use serialize::{Encodable, Decodable, Encoder, Decoder}; use std::collections::HashMap; @@ -190,7 +190,6 @@ pub struct HygieneData { marks: Vec<MarkData>, syntax_contexts: Vec<SyntaxContextData>, markings: HashMap<(SyntaxContext, Mark), SyntaxContext>, - gensym_to_ctxt: HashMap<Symbol, Span>, default_edition: Edition, } @@ -211,7 +210,6 @@ impl HygieneData { modern: SyntaxContext(0), }], markings: HashMap::new(), - gensym_to_ctxt: HashMap::new(), default_edition: Edition::Edition2015, } } @@ -559,22 +557,3 @@ impl Decodable for SyntaxContext { Ok(SyntaxContext::empty()) // FIXME(jseyfried) intercrate hygiene } } - -impl Symbol { - pub fn from_ident(ident: Ident) -> Symbol { - HygieneData::with(|data| { - let gensym = ident.name.gensymed(); - data.gensym_to_ctxt.insert(gensym, ident.span); - gensym - }) - } - - pub fn to_ident(self) -> Ident { - HygieneData::with(|data| { - match data.gensym_to_ctxt.get(&self) { - Some(&span) => Ident::new(self.interned(), span), - None => Ident::with_empty_ctxt(self), - } - }) - } -} |
