@@ -168,7 +168,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
168168 let all_candidate_names: Vec < _ > = all_candidates ( )
169169 . flat_map ( |r| tcx. associated_items ( r. def_id ( ) ) . in_definition_order ( ) )
170170 . 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+ }
172176 } )
173177 . collect ( ) ;
174178
@@ -200,7 +204,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
200204 . iter ( )
201205 . flat_map ( |trait_def_id| tcx. associated_items ( * trait_def_id) . in_definition_order ( ) )
202206 . 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 ( ) )
204209 } )
205210 . collect ( ) ;
206211
@@ -337,7 +342,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
337342 ) -> ErrorGuaranteed {
338343 let tcx = self . tcx ( ) ;
339344
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
341346 && let Some ( constraint) = constraint
342347 && let hir:: AssocItemConstraintKind :: Bound { .. } = constraint. kind
343348 {
@@ -761,7 +766,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
761766 // `issue-22560.rs`.
762767 let mut dyn_compatibility_violations = Ok ( ( ) ) ;
763768 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 ( ) ) ;
765770 names_len += 1 ;
766771
767772 let violations =
@@ -852,16 +857,17 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
852857 let mut names: UnordMap < _ , usize > = Default :: default ( ) ;
853858 for ( item, _) in & missing_assoc_types {
854859 types_count += 1 ;
855- * names. entry ( item. name ) . or_insert ( 0 ) += 1 ;
860+ * names. entry ( item. name ( ) ) . or_insert ( 0 ) += 1 ;
856861 }
857862 let mut dupes = false ;
858863 let mut shadows = false ;
859864 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 {
861867 let trait_def_id = trait_ref. def_id ( ) ;
862868 dupes = true ;
863869 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) {
865871 let trait_def_id = trait_ref. def_id ( ) ;
866872 shadows = true ;
867873 format ! ( "{}::" , tcx. def_path_str( trait_def_id) )
@@ -871,7 +877,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
871877
872878 let mut is_shadowed = false ;
873879
874- if let Some ( assoc_item) = bound_names. get ( & item . name )
880+ if let Some ( assoc_item) = bound_names. get ( & name)
875881 && * assoc_item != item
876882 {
877883 is_shadowed = true ;
@@ -880,17 +886,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
880886 if assoc_item. def_id . is_local ( ) { ", consider renaming it" } else { "" } ;
881887 err. span_label (
882888 tcx. def_span ( assoc_item. def_id ) ,
883- format ! ( "`{}{}` shadowed here{}" , prefix, item . name, rename_message) ,
889+ format ! ( "`{}{}` shadowed here{}" , prefix, name, rename_message) ,
884890 ) ;
885891 }
886892
887893 let rename_message = if is_shadowed { ", consider renaming it" } else { "" } ;
888894
889895 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) ) ;
894897 }
895898 }
896899 if potential_assoc_types. len ( ) == missing_assoc_types. len ( ) {
@@ -903,7 +906,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
903906 {
904907 let types: Vec < _ > = missing_assoc_types
905908 . iter ( )
906- . map ( |( item, _) | format ! ( "{} = Type" , item. name) )
909+ . map ( |( item, _) | format ! ( "{} = Type" , item. name( ) ) )
907910 . collect ( ) ;
908911 let code = if let Some ( snippet) = snippet. strip_suffix ( '>' ) {
909912 // 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> + '_ {
938941 let mut names: FxIndexMap < _ , usize > = FxIndexMap :: default ( ) ;
939942 for ( item, _) in & missing_assoc_types {
940943 types_count += 1 ;
941- * names. entry ( item. name ) . or_insert ( 0 ) += 1 ;
944+ * names. entry ( item. name ( ) ) . or_insert ( 0 ) += 1 ;
942945 }
943946 let mut label = vec ! [ ] ;
944947 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 {
946950 format ! ( " (from trait `{}`)" , trait_ref. print_trait_sugared( ) )
947951 } else {
948952 String :: new ( )
949953 } ;
950- label. push ( format ! ( "`{}`{}" , item . name, postfix) ) ;
954+ label. push ( format ! ( "`{}`{}" , name, postfix) ) ;
951955 }
952956 if !label. is_empty ( ) {
953957 err. span_label (
0 commit comments