@@ -168,7 +168,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
168
168
let all_candidate_names: Vec < _ > = all_candidates ( )
169
169
. flat_map ( |r| tcx. associated_items ( r. def_id ( ) ) . in_definition_order ( ) )
170
170
. filter_map ( |item| {
171
- ( !item. is_impl_trait_in_trait ( ) && item. as_tag ( ) == assoc_tag) . then_some ( item. name )
171
+ if !item. is_impl_trait_in_trait ( ) && item. as_tag ( ) == assoc_tag {
172
+ item. opt_name ( )
173
+ } else {
174
+ None
175
+ }
172
176
} )
173
177
. collect ( ) ;
174
178
@@ -200,7 +204,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
200
204
. iter ( )
201
205
. flat_map ( |trait_def_id| tcx. associated_items ( * trait_def_id) . in_definition_order ( ) )
202
206
. filter_map ( |item| {
203
- ( !item. is_impl_trait_in_trait ( ) && item. as_tag ( ) == assoc_tag) . then_some ( item. name )
207
+ ( !item. is_impl_trait_in_trait ( ) && item. as_tag ( ) == assoc_tag)
208
+ . then_some ( item. name ( ) )
204
209
} )
205
210
. collect ( ) ;
206
211
@@ -337,7 +342,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
337
342
) -> ErrorGuaranteed {
338
343
let tcx = self . tcx ( ) ;
339
344
340
- let bound_on_assoc_const_label = if let ty:: AssocKind :: Const = assoc_item. kind
345
+ let bound_on_assoc_const_label = if let ty:: AssocKind :: Const { .. } = assoc_item. kind
341
346
&& let Some ( constraint) = constraint
342
347
&& let hir:: AssocItemConstraintKind :: Bound { .. } = constraint. kind
343
348
{
@@ -761,7 +766,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
761
766
// `issue-22560.rs`.
762
767
let mut dyn_compatibility_violations = Ok ( ( ) ) ;
763
768
for ( assoc_item, trait_ref) in & missing_assoc_types {
764
- names. entry ( trait_ref) . or_default ( ) . push ( assoc_item. name ) ;
769
+ names. entry ( trait_ref) . or_default ( ) . push ( assoc_item. name ( ) ) ;
765
770
names_len += 1 ;
766
771
767
772
let violations =
@@ -852,16 +857,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
852
857
let mut names: UnordMap < _ , usize > = Default :: default ( ) ;
853
858
for ( item, _) in & missing_assoc_types {
854
859
types_count += 1 ;
855
- * names. entry ( item. name ) . or_insert ( 0 ) += 1 ;
860
+ * names. entry ( item. name ( ) ) . or_insert ( 0 ) += 1 ;
856
861
}
857
862
let mut dupes = false ;
858
863
let mut shadows = false ;
859
864
for ( item, trait_ref) in & missing_assoc_types {
860
- let prefix = if names[ & item. name ] > 1 {
865
+ let name = item. name ( ) ;
866
+ let prefix = if names[ & name] > 1 {
861
867
let trait_def_id = trait_ref. def_id ( ) ;
862
868
dupes = true ;
863
869
format ! ( "{}::" , tcx. def_path_str( trait_def_id) )
864
- } else if bound_names. get ( & item . name ) . is_some_and ( |x| * x != item) {
870
+ } else if bound_names. get ( & name) . is_some_and ( |x| * x != item) {
865
871
let trait_def_id = trait_ref. def_id ( ) ;
866
872
shadows = true ;
867
873
format ! ( "{}::" , tcx. def_path_str( trait_def_id) )
@@ -871,7 +877,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
871
877
872
878
let mut is_shadowed = false ;
873
879
874
- if let Some ( assoc_item) = bound_names. get ( & item . name )
880
+ if let Some ( assoc_item) = bound_names. get ( & name)
875
881
&& * assoc_item != item
876
882
{
877
883
is_shadowed = true ;
@@ -880,17 +886,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
880
886
if assoc_item. def_id . is_local ( ) { ", consider renaming it" } else { "" } ;
881
887
err. span_label (
882
888
tcx. def_span ( assoc_item. def_id ) ,
883
- format ! ( "`{}{}` shadowed here{}" , prefix, item . name, rename_message) ,
889
+ format ! ( "`{}{}` shadowed here{}" , prefix, name, rename_message) ,
884
890
) ;
885
891
}
886
892
887
893
let rename_message = if is_shadowed { ", consider renaming it" } else { "" } ;
888
894
889
895
if let Some ( sp) = tcx. hir_span_if_local ( item. def_id ) {
890
- err. span_label (
891
- sp,
892
- format ! ( "`{}{}` defined here{}" , prefix, item. name, rename_message) ,
893
- ) ;
896
+ err. span_label ( sp, format ! ( "`{}{}` defined here{}" , prefix, name, rename_message) ) ;
894
897
}
895
898
}
896
899
if potential_assoc_types. len ( ) == missing_assoc_types. len ( ) {
@@ -903,7 +906,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
903
906
{
904
907
let types: Vec < _ > = missing_assoc_types
905
908
. iter ( )
906
- . map ( |( item, _) | format ! ( "{} = Type" , item. name) )
909
+ . map ( |( item, _) | format ! ( "{} = Type" , item. name( ) ) )
907
910
. collect ( ) ;
908
911
let code = if let Some ( snippet) = snippet. strip_suffix ( '>' ) {
909
912
// The user wrote `Trait<'a>` or similar and we don't have a type we can
@@ -938,16 +941,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
938
941
let mut names: FxIndexMap < _ , usize > = FxIndexMap :: default ( ) ;
939
942
for ( item, _) in & missing_assoc_types {
940
943
types_count += 1 ;
941
- * names. entry ( item. name ) . or_insert ( 0 ) += 1 ;
944
+ * names. entry ( item. name ( ) ) . or_insert ( 0 ) += 1 ;
942
945
}
943
946
let mut label = vec ! [ ] ;
944
947
for ( item, trait_ref) in & missing_assoc_types {
945
- let postfix = if names[ & item. name ] > 1 {
948
+ let name = item. name ( ) ;
949
+ let postfix = if names[ & name] > 1 {
946
950
format ! ( " (from trait `{}`)" , trait_ref. print_trait_sugared( ) )
947
951
} else {
948
952
String :: new ( )
949
953
} ;
950
- label. push ( format ! ( "`{}`{}" , item . name, postfix) ) ;
954
+ label. push ( format ! ( "`{}`{}" , name, postfix) ) ;
951
955
}
952
956
if !label. is_empty ( ) {
953
957
err. span_label (
0 commit comments