Skip to content

Commit ade1d28

Browse files
committed
Use Idents for associated type bindings in HIR
1 parent 897f6a5 commit ade1d28

File tree

15 files changed

+38
-36
lines changed

15 files changed

+38
-36
lines changed

src/librustc/hir/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ pub fn walk_path_parameters<'v, V: Visitor<'v>>(visitor: &mut V,
651651
pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
652652
type_binding: &'v TypeBinding) {
653653
visitor.visit_id(type_binding.id);
654-
visitor.visit_name(type_binding.span, type_binding.name);
654+
visitor.visit_ident(type_binding.ident);
655655
visitor.visit_ty(&type_binding.ty);
656656
}
657657

src/librustc/hir/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ impl<'a> LoweringContext<'a> {
10081008
fn lower_ty_binding(&mut self, b: &TypeBinding, itctx: ImplTraitContext) -> hir::TypeBinding {
10091009
hir::TypeBinding {
10101010
id: self.lower_node_id(b.id).node_id,
1011-
name: self.lower_ident(b.ident),
1011+
ident: b.ident,
10121012
ty: self.lower_ty(&b.ty, itctx),
10131013
span: b.span,
10141014
}
@@ -1676,7 +1676,7 @@ impl<'a> LoweringContext<'a> {
16761676
bindings: hir_vec![
16771677
hir::TypeBinding {
16781678
id: this.next_id().node_id,
1679-
name: Symbol::intern(FN_OUTPUT_NAME),
1679+
ident: Ident::from_str(FN_OUTPUT_NAME),
16801680
ty: output
16811681
.as_ref()
16821682
.map(|ty| this.lower_ty(&ty, DISALLOWED))

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ pub enum ImplItemKind {
16601660
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
16611661
pub struct TypeBinding {
16621662
pub id: NodeId,
1663-
pub name: Name,
1663+
pub ident: Ident,
16641664
pub ty: P<Ty>,
16651665
pub span: Span,
16661666
}

src/librustc/hir/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ impl<'a> State<'a> {
17151715

17161716
for binding in parameters.bindings.iter() {
17171717
start_or_comma(self)?;
1718-
self.print_name(binding.name)?;
1718+
self.print_ident(binding.ident)?;
17191719
self.s.space()?;
17201720
self.word_space("=")?;
17211721
self.print_type(&binding.ty)?;

src/librustc/ich/impls_hir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl_stable_hash_for!(struct hir::MethodSig {
268268

269269
impl_stable_hash_for!(struct hir::TypeBinding {
270270
id,
271-
name,
271+
ident,
272272
ty,
273273
span
274274
});

src/librustc/traits/project.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use infer::type_variable::TypeVariableOrigin;
3131
use middle::const_val::ConstVal;
3232
use mir::interpret::{GlobalId};
3333
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
34+
use syntax::ast::Ident;
3435
use syntax::symbol::Symbol;
3536
use ty::subst::{Subst, Substs};
3637
use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
@@ -1452,7 +1453,7 @@ fn confirm_callable_candidate<'cx, 'gcx, 'tcx>(
14521453
projection_ty: ty::ProjectionTy::from_ref_and_name(
14531454
tcx,
14541455
trait_ref,
1455-
Symbol::intern(FN_OUTPUT_NAME),
1456+
Ident::from_str(FN_OUTPUT_NAME),
14561457
),
14571458
ty: ret_type
14581459
}
@@ -1546,7 +1547,7 @@ fn assoc_ty_def<'cx, 'gcx, 'tcx>(
15461547
let impl_node = specialization_graph::Node::Impl(impl_def_id);
15471548
for item in impl_node.items(tcx) {
15481549
if item.kind == ty::AssociatedKind::Type &&
1549-
tcx.hygienic_eq(item.name, assoc_ty_name, trait_def_id) {
1550+
tcx.hygienic_eq(item.name.to_ident(), assoc_ty_name.to_ident(), trait_def_id) {
15501551
return specialization_graph::NodeItem {
15511552
node: specialization_graph::Node::Impl(impl_def_id),
15521553
item,

src/librustc/traits/specialize/specialization_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl<'a, 'gcx, 'tcx> Ancestors {
379379
self.flat_map(move |node| {
380380
node.items(tcx).filter(move |impl_item| {
381381
impl_item.kind == trait_item_kind &&
382-
tcx.hygienic_eq(impl_item.name, trait_item_name, trait_def_id)
382+
tcx.hygienic_eq(impl_item.name.to_ident(), trait_item_name.to_ident(), trait_def_id)
383383
}).map(move |item| NodeItem { node: node, item: item })
384384
})
385385
}

src/librustc/ty/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,9 +2720,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
27202720
// Hygienically compare a use-site name (`use_name`) for a field or an associated item with its
27212721
// supposed definition name (`def_name`). The method also needs `DefId` of the supposed
27222722
// definition's parent/scope to perform comparison.
2723-
pub fn hygienic_eq(self, use_name: Name, def_name: Name, def_parent_def_id: DefId) -> bool {
2724-
let (use_ident, def_ident) = (use_name.to_ident(), def_name.to_ident());
2725-
self.adjust_ident(use_ident, def_parent_def_id, DUMMY_NODE_ID).0 == def_ident
2723+
pub fn hygienic_eq(self, use_name: Ident, def_name: Ident, def_parent_def_id: DefId) -> bool {
2724+
self.adjust_ident(use_name, def_parent_def_id, DUMMY_NODE_ID).0 == def_name.modern()
27262725
}
27272726

27282727
pub fn adjust_ident(self, mut ident: Ident, scope: DefId, block: NodeId) -> (Ident, DefId) {

src/librustc/ty/sty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use mir::interpret::{Scalar, Pointer, Value, ConstValue};
2525
use std::iter;
2626
use std::cmp::Ordering;
2727
use rustc_target::spec::abi;
28-
use syntax::ast::{self, Name};
28+
use syntax::ast::{self, Ident};
2929
use syntax::symbol::{keywords, InternedString};
3030

3131
use serialize;
@@ -851,11 +851,11 @@ impl<'a, 'tcx> ProjectionTy<'tcx> {
851851
/// Construct a ProjectionTy by searching the trait from trait_ref for the
852852
/// associated item named item_name.
853853
pub fn from_ref_and_name(
854-
tcx: TyCtxt, trait_ref: ty::TraitRef<'tcx>, item_name: Name
854+
tcx: TyCtxt, trait_ref: ty::TraitRef<'tcx>, item_name: Ident
855855
) -> ProjectionTy<'tcx> {
856856
let item_def_id = tcx.associated_items(trait_ref.def_id).find(|item| {
857857
item.kind == ty::AssociatedKind::Type &&
858-
tcx.hygienic_eq(item_name, item.name, trait_ref.def_id)
858+
tcx.hygienic_eq(item_name, item.name.to_ident(), trait_ref.def_id)
859859
}).unwrap().def_id;
860860

861861
ProjectionTy {

src/librustc_traits/lowering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
332332
let mut where_clauses = vec![trait_implemented];
333333
where_clauses.extend(item_where_clauses);
334334
// `<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm>`
335-
let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.name);
335+
let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.name.to_ident());
336336
// `Normalize(<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm> -> T)`
337337
let normalize_goal = DomainGoal::Normalize(ty::ProjectionPredicate { projection_ty, ty });
338338
// `Normalize(... -> T) :- ...`

0 commit comments

Comments
 (0)