@@ -356,9 +356,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
356
356
poly_projections. extend ( assoc_bindings. iter ( ) . filter_map ( |binding| {
357
357
// specify type to assert that error was already reported in Err case:
358
358
let predicate: Result < _ , ErrorReported > =
359
- self . ast_type_binding_to_poly_projection_predicate ( trait_ref. ref_id ,
360
- poly_trait_ref,
361
- binding) ;
359
+ self . ast_type_binding_to_poly_projection_predicate ( poly_trait_ref, binding) ;
362
360
predicate. ok ( ) // ok to ignore Err() because ErrorReported (see above)
363
361
} ) ) ;
364
362
@@ -423,13 +421,13 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
423
421
-> bool
424
422
{
425
423
self . tcx ( ) . associated_items ( trait_def_id) . any ( |item| {
426
- item. kind == ty:: AssociatedKind :: Type && item. name == assoc_name
424
+ item. kind == ty:: AssociatedKind :: Type &&
425
+ self . tcx ( ) . hygienic_eq ( assoc_name, item. name , trait_def_id)
427
426
} )
428
427
}
429
428
430
429
fn ast_type_binding_to_poly_projection_predicate (
431
430
& self ,
432
- _path_id : ast:: NodeId ,
433
431
trait_ref : ty:: PolyTraitRef < ' tcx > ,
434
432
binding : & ConvertedBinding < ' tcx > )
435
433
-> Result < ty:: PolyProjectionPredicate < ' tcx > , ErrorReported >
@@ -504,7 +502,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
504
502
505
503
let candidate = self . one_bound_for_assoc_type ( candidates,
506
504
& trait_ref. to_string ( ) ,
507
- & binding. item_name . as_str ( ) ,
505
+ binding. item_name ,
508
506
binding. span ) ?;
509
507
510
508
Ok ( candidate. map_bound ( |trait_ref| {
@@ -702,7 +700,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
702
700
let param_name = tcx. hir . ty_param_name ( param_node_id) ;
703
701
self . one_bound_for_assoc_type ( suitable_bounds,
704
702
& param_name. as_str ( ) ,
705
- & assoc_name. as_str ( ) ,
703
+ assoc_name,
706
704
span)
707
705
}
708
706
@@ -712,7 +710,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
712
710
fn one_bound_for_assoc_type < I > ( & self ,
713
711
mut bounds : I ,
714
712
ty_param_name : & str ,
715
- assoc_name : & str ,
713
+ assoc_name : ast :: Name ,
716
714
span : Span )
717
715
-> Result < ty:: PolyTraitRef < ' tcx > , ErrorReported >
718
716
where I : Iterator < Item =ty:: PolyTraitRef < ' tcx > >
@@ -741,7 +739,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
741
739
742
740
for bound in bounds {
743
741
let bound_span = self . tcx ( ) . associated_items ( bound. def_id ( ) ) . find ( |item| {
744
- item. kind == ty:: AssociatedKind :: Type && item. name == assoc_name
742
+ item. kind == ty:: AssociatedKind :: Type &&
743
+ self . tcx ( ) . hygienic_eq ( assoc_name, item. name , bound. def_id ( ) )
745
744
} )
746
745
. and_then ( |item| self . tcx ( ) . hir . span_if_local ( item. def_id ) ) ;
747
746
@@ -802,10 +801,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
802
801
. filter ( |r| self . trait_defines_associated_type_named ( r. def_id ( ) ,
803
802
assoc_name) ) ;
804
803
805
- match self . one_bound_for_assoc_type ( candidates,
806
- "Self" ,
807
- & assoc_name. as_str ( ) ,
808
- span) {
804
+ match self . one_bound_for_assoc_type ( candidates, "Self" , assoc_name, span) {
809
805
Ok ( bound) => bound,
810
806
Err ( ErrorReported ) => return ( tcx. types . err , Def :: Err ) ,
811
807
}
@@ -830,14 +826,14 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
830
826
} ;
831
827
832
828
let trait_did = bound. 0 . def_id ;
833
- let item = tcx. associated_items ( trait_did) . find ( |i| i. name == assoc_name)
829
+ let ( assoc_ident, def_scope) = tcx. adjust ( assoc_name, trait_did, ref_id) ;
830
+ let item = tcx. associated_items ( trait_did) . find ( |i| i. name . to_ident ( ) == assoc_ident)
834
831
. expect ( "missing associated type" ) ;
835
832
836
833
let ty = self . projected_ty_from_poly_trait_ref ( span, item. def_id , bound) ;
837
834
let ty = self . normalize_ty ( span, ty) ;
838
835
839
836
let def = Def :: AssociatedTy ( item. def_id ) ;
840
- let def_scope = tcx. adjust ( assoc_name, item. container . id ( ) , ref_id) . 1 ;
841
837
if !item. vis . is_accessible_from ( def_scope, tcx) {
842
838
let msg = format ! ( "{} `{}` is private" , def. kind_name( ) , assoc_name) ;
843
839
tcx. sess . span_err ( span, & msg) ;
0 commit comments