Skip to content

Commit 1fe9b4d

Browse files
committed
Use Idents for associated type bindings in HIR
1 parent c5454c0 commit 1fe9b4d

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
@@ -660,7 +660,7 @@ pub fn walk_generic_args<'v, V: Visitor<'v>>(visitor: &mut V,
660660
pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>(visitor: &mut V,
661661
type_binding: &'v TypeBinding) {
662662
visitor.visit_id(type_binding.id);
663-
visitor.visit_name(type_binding.span, type_binding.name);
663+
visitor.visit_ident(type_binding.ident);
664664
visitor.visit_ty(&type_binding.ty);
665665
}
666666

src/librustc/hir/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ impl<'a> LoweringContext<'a> {
10641064
fn lower_ty_binding(&mut self, b: &TypeBinding, itctx: ImplTraitContext) -> hir::TypeBinding {
10651065
hir::TypeBinding {
10661066
id: self.lower_node_id(b.id).node_id,
1067-
name: self.lower_ident(b.ident),
1067+
ident: b.ident,
10681068
ty: self.lower_ty(&b.ty, itctx),
10691069
span: b.span,
10701070
}
@@ -1820,7 +1820,7 @@ impl<'a> LoweringContext<'a> {
18201820
bindings: hir_vec![
18211821
hir::TypeBinding {
18221822
id: this.next_id().node_id,
1823-
name: Symbol::intern(FN_OUTPUT_NAME),
1823+
ident: Ident::from_str(FN_OUTPUT_NAME),
18241824
ty: output
18251825
.as_ref()
18261826
.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
@@ -1607,7 +1607,7 @@ pub enum ImplItemKind {
16071607
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
16081608
pub struct TypeBinding {
16091609
pub id: NodeId,
1610-
pub name: Name,
1610+
pub ident: Ident,
16111611
pub ty: P<Ty>,
16121612
pub span: Span,
16131613
}

src/librustc/hir/print.rs

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

17631763
for binding in generic_args.bindings.iter() {
17641764
start_or_comma(self)?;
1765-
self.print_name(binding.name)?;
1765+
self.print_ident(binding.ident)?;
17661766
self.s.space()?;
17671767
self.word_space("=")?;
17681768
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
@@ -278,7 +278,7 @@ impl_stable_hash_for!(struct hir::MethodSig {
278278

279279
impl_stable_hash_for!(struct hir::TypeBinding {
280280
id,
281-
name,
281+
ident,
282282
ty,
283283
span
284284
});

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
@@ -2717,9 +2717,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
27172717
// Hygienically compare a use-site name (`use_name`) for a field or an associated item with its
27182718
// supposed definition name (`def_name`). The method also needs `DefId` of the supposed
27192719
// definition's parent/scope to perform comparison.
2720-
pub fn hygienic_eq(self, use_name: Name, def_name: Name, def_parent_def_id: DefId) -> bool {
2721-
let (use_ident, def_ident) = (use_name.to_ident(), def_name.to_ident());
2722-
self.adjust_ident(use_ident, def_parent_def_id, DUMMY_NODE_ID).0 == def_ident
2720+
pub fn hygienic_eq(self, use_name: Ident, def_name: Ident, def_parent_def_id: DefId) -> bool {
2721+
self.adjust_ident(use_name, def_parent_def_id, DUMMY_NODE_ID).0 == def_name.modern()
27232722
}
27242723

27252724
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;
@@ -853,11 +853,11 @@ impl<'a, 'tcx> ProjectionTy<'tcx> {
853853
/// Construct a ProjectionTy by searching the trait from trait_ref for the
854854
/// associated item named item_name.
855855
pub fn from_ref_and_name(
856-
tcx: TyCtxt, trait_ref: ty::TraitRef<'tcx>, item_name: Name
856+
tcx: TyCtxt, trait_ref: ty::TraitRef<'tcx>, item_name: Ident
857857
) -> ProjectionTy<'tcx> {
858858
let item_def_id = tcx.associated_items(trait_ref.def_id).find(|item| {
859859
item.kind == ty::AssociatedKind::Type &&
860-
tcx.hygienic_eq(item_name, item.name, trait_ref.def_id)
860+
tcx.hygienic_eq(item_name, item.name.to_ident(), trait_ref.def_id)
861861
}).unwrap().def_id;
862862

863863
ProjectionTy {

src/librustc_traits/lowering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
417417
let hypotheses = vec![trait_implemented];
418418

419419
// `<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm>`
420-
let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.name);
420+
let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.name.to_ident());
421421

422422
// `Normalize(<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm> -> T)`
423423
let normalize_goal = DomainGoal::Normalize(ty::ProjectionPredicate { projection_ty, ty });

0 commit comments

Comments
 (0)