diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index bb8b0fd8e01..12ca0d41d08 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -660,7 +660,7 @@ pub fn walk_generic_args<'v, V: Visitor<'v>>(visitor: &mut V, pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V, type_binding: &'v TypeBinding) { visitor.visit_id(type_binding.id); - visitor.visit_name(type_binding.span, type_binding.name); + visitor.visit_ident(type_binding.ident); visitor.visit_ty(&type_binding.ty); } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 561097e9afc..5e2bfc113ea 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1064,7 +1064,7 @@ impl<'a> LoweringContext<'a> { fn lower_ty_binding(&mut self, b: &TypeBinding, itctx: ImplTraitContext) -> hir::TypeBinding { hir::TypeBinding { id: self.lower_node_id(b.id).node_id, - name: self.lower_ident(b.ident), + ident: b.ident, ty: self.lower_ty(&b.ty, itctx), span: b.span, } @@ -1820,7 +1820,7 @@ impl<'a> LoweringContext<'a> { bindings: hir_vec![ hir::TypeBinding { id: this.next_id().node_id, - name: Symbol::intern(FN_OUTPUT_NAME), + ident: Ident::from_str(FN_OUTPUT_NAME), ty: output .as_ref() .map(|ty| this.lower_ty(&ty, DISALLOWED)) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index dedc276dcc3..3206c2fce20 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1607,7 +1607,7 @@ pub enum ImplItemKind { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct TypeBinding { pub id: NodeId, - pub name: Name, + pub ident: Ident, pub ty: P, pub span: Span, } diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 6db4e987840..05ceb1fcfcd 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -1762,7 +1762,7 @@ impl<'a> State<'a> { for binding in generic_args.bindings.iter() { start_or_comma(self)?; - self.print_name(binding.name)?; + self.print_ident(binding.ident)?; self.s.space()?; self.word_space("=")?; self.print_type(&binding.ty)?; diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index b71b69474a7..cad76c4100c 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -278,7 +278,7 @@ impl_stable_hash_for!(struct hir::MethodSig { impl_stable_hash_for!(struct hir::TypeBinding { id, - name, + ident, ty, span }); diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 82f351782bb..77077732dcf 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -31,6 +31,7 @@ use infer::type_variable::TypeVariableOrigin; 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}; @@ -1452,7 +1453,7 @@ fn confirm_callable_candidate<'cx, 'gcx, 'tcx>( projection_ty: ty::ProjectionTy::from_ref_and_name( tcx, trait_ref, - Symbol::intern(FN_OUTPUT_NAME), + Ident::from_str(FN_OUTPUT_NAME), ), ty: ret_type } @@ -1546,7 +1547,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, assoc_ty_name, trait_def_id) { + tcx.hygienic_eq(item.name.to_ident(), assoc_ty_name.to_ident(), trait_def_id) { return specialization_graph::NodeItem { node: specialization_graph::Node::Impl(impl_def_id), item, diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index e56a8662f3e..9b0edf42fdf 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -379,7 +379,7 @@ impl<'a, 'gcx, 'tcx> Ancestors { self.flat_map(move |node| { node.items(tcx).filter(move |impl_item| { impl_item.kind == trait_item_kind && - tcx.hygienic_eq(impl_item.name, trait_item_name, trait_def_id) + tcx.hygienic_eq(impl_item.name.to_ident(), trait_item_name.to_ident(), 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 e89a022f818..686c560fe84 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2717,9 +2717,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // Hygienically compare a use-site name (`use_name`) for a field or an associated item with its // supposed definition name (`def_name`). The method also needs `DefId` of the supposed // definition's parent/scope to perform comparison. - pub fn hygienic_eq(self, use_name: Name, def_name: Name, def_parent_def_id: DefId) -> bool { - let (use_ident, def_ident) = (use_name.to_ident(), def_name.to_ident()); - self.adjust_ident(use_ident, def_parent_def_id, DUMMY_NODE_ID).0 == def_ident + pub fn hygienic_eq(self, use_name: Ident, def_name: Ident, def_parent_def_id: DefId) -> bool { + self.adjust_ident(use_name, def_parent_def_id, DUMMY_NODE_ID).0 == def_name.modern() } pub fn adjust_ident(self, mut ident: Ident, scope: DefId, block: NodeId) -> (Ident, DefId) { diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 412dc7dc7e7..a34e1e43009 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -25,7 +25,7 @@ use mir::interpret::{Scalar, Pointer, Value, ConstValue}; use std::iter; use std::cmp::Ordering; use rustc_target::spec::abi; -use syntax::ast::{self, Name}; +use syntax::ast::{self, Ident}; use syntax::symbol::{keywords, InternedString}; use serialize; @@ -853,11 +853,11 @@ impl<'a, 'tcx> ProjectionTy<'tcx> { /// Construct a ProjectionTy by searching the trait from trait_ref for the /// associated item named item_name. pub fn from_ref_and_name( - tcx: TyCtxt, trait_ref: ty::TraitRef<'tcx>, item_name: Name + tcx: TyCtxt, trait_ref: ty::TraitRef<'tcx>, item_name: Ident ) -> 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, trait_ref.def_id) + tcx.hygienic_eq(item_name, item.name.to_ident(), trait_ref.def_id) }).unwrap().def_id; ProjectionTy { diff --git a/src/librustc_traits/lowering.rs b/src/librustc_traits/lowering.rs index 16aa63d6999..137a6b5c78d 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]; // `>::AssocType` - let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.name); + let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.name.to_ident()); // `Normalize(>::AssocType -> 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 f3912c3042d..e8094dc2704 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -83,7 +83,7 @@ pub trait AstConv<'gcx, 'tcx> { } struct ConvertedBinding<'tcx> { - item_name: ast::Name, + item_name: ast::Ident, ty: Ty<'tcx>, span: Span, } @@ -342,7 +342,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { let assoc_bindings = generic_args.bindings.iter().map(|binding| { ConvertedBinding { - item_name: binding.name, + item_name: binding.ident, ty: self.ast_ty_to_ty(&binding.ty), span: binding.span, } @@ -485,12 +485,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { fn trait_defines_associated_type_named(&self, trait_def_id: DefId, - assoc_name: ast::Name) + assoc_name: ast::Ident) -> bool { self.tcx().associated_items(trait_def_id).any(|item| { item.kind == ty::AssociatedKind::Type && - self.tcx().hygienic_eq(assoc_name, item.name, trait_def_id) + self.tcx().hygienic_eq(assoc_name, item.name.to_ident(), trait_def_id) }) } @@ -569,7 +569,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { }?; let (assoc_ident, def_scope) = - tcx.adjust_ident(binding.item_name.to_ident(), candidate.def_id(), ref_id); + 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 }).expect("missing associated type"); @@ -778,7 +778,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { // any ambiguity. fn find_bound_for_assoc_item(&self, ty_param_def_id: DefId, - assoc_name: ast::Name, + assoc_name: ast::Ident, span: Span) -> Result, ErrorReported> { @@ -807,7 +807,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { fn one_bound_for_assoc_type(&self, mut bounds: I, ty_param_name: &str, - assoc_name: ast::Name, + assoc_name: ast::Ident, span: Span) -> Result, ErrorReported> where I: Iterator> @@ -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, bound.def_id()) + self.tcx().hygienic_eq(assoc_name, item.name.to_ident(), bound.def_id()) }) .and_then(|item| self.tcx().hir.span_if_local(item.def_id)); @@ -873,7 +873,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { -> (Ty<'tcx>, Def) { let tcx = self.tcx(); - let assoc_name = item_segment.name; + let assoc_name = item_segment.name.to_ident(); debug!("associated_path_def_to_ty: {:?}::{}", ty, assoc_name); @@ -895,8 +895,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { let candidates = traits::supertraits(tcx, ty::Binder::bind(trait_ref)) - .filter(|r| self.trait_defines_associated_type_named(r.def_id(), - assoc_name)); + .filter(|r| self.trait_defines_associated_type_named(r.def_id(), assoc_name)); match self.one_bound_for_assoc_type(candidates, "Self", assoc_name, span) { Ok(bound) => bound, @@ -923,7 +922,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { }; let trait_did = bound.def_id(); - let (assoc_ident, def_scope) = tcx.adjust_ident(assoc_name.to_ident(), trait_did, ref_id); + 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 diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs index 4274e5c1e1f..09562614982 100644 --- a/src/librustc_typeck/check/autoderef.rs +++ b/src/librustc_typeck/check/autoderef.rs @@ -21,7 +21,7 @@ use rustc::ty::{ToPredicate, TypeFoldable}; use rustc::ty::adjustment::{Adjustment, Adjust, OverloadedDeref}; use syntax_pos::Span; -use syntax::symbol::Symbol; +use syntax::ast::Ident; use std::iter; @@ -134,7 +134,7 @@ impl<'a, 'gcx, 'tcx> Autoderef<'a, 'gcx, 'tcx> { ty::ProjectionTy::from_ref_and_name( tcx, trait_ref, - Symbol::intern("Target"), + Ident::from_str("Target"), ), cause, 0, diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index a51876d7960..feb99f4b593 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -387,8 +387,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { /// and return it, or `None`, if no such item was defined there. pub fn associated_item(&self, def_id: DefId, item_name: ast::Name, ns: Namespace) -> Option { - self.tcx.associated_items(def_id) - .find(|item| Namespace::from(item.kind) == ns && - self.tcx.hygienic_eq(item_name, item.name, def_id)) + self.tcx.associated_items(def_id).find(|item| { + Namespace::from(item.kind) == ns && + self.tcx.hygienic_eq(item_name.to_ident(), item.name.to_ident(), def_id) + }) } } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 889073f6b4c..82df956b54d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1400,11 +1400,13 @@ 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, ac.name, impl_trait_ref.def_id)) + tcx.hygienic_eq(ty_impl_item.name.to_ident(), ac.name.to_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, ac.name, 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)) }); // Check that impl definition matches trait definition diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 274269ef53a..3a1390bb3c2 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -4293,7 +4293,7 @@ pub struct TypeBinding { impl Clean for hir::TypeBinding { fn clean(&self, cx: &DocContext) -> TypeBinding { TypeBinding { - name: self.name.clean(cx), + name: self.ident.name.clean(cx), ty: self.ty.clean(cx) } }