@@ -789,115 +789,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
789789 }
790790 }
791791
792- fn report_ambiguous_assoc_type (
793- & self ,
794- span : Span ,
795- types : & [ String ] ,
796- traits : & [ String ] ,
797- name : Symbol ,
798- ) -> ErrorGuaranteed {
799- let mut err =
800- struct_span_code_err ! ( self . tcx( ) . dcx( ) , span, E0223 , "ambiguous associated type" ) ;
801- if self
802- . tcx ( )
803- . resolutions ( ( ) )
804- . confused_type_with_std_module
805- . keys ( )
806- . any ( |full_span| full_span. contains ( span) )
807- {
808- err. span_suggestion_verbose (
809- span. shrink_to_lo ( ) ,
810- "you are looking for the module in `std`, not the primitive type" ,
811- "std::" ,
812- Applicability :: MachineApplicable ,
813- ) ;
814- } else {
815- let mut types = types. to_vec ( ) ;
816- types. sort ( ) ;
817- let mut traits = traits. to_vec ( ) ;
818- traits. sort ( ) ;
819- match ( & types[ ..] , & traits[ ..] ) {
820- ( [ ] , [ ] ) => {
821- err. span_suggestion_verbose (
822- span,
823- format ! (
824- "if there were a type named `Type` that implements a trait named \
825- `Trait` with associated type `{name}`, you could use the \
826- fully-qualified path",
827- ) ,
828- format ! ( "<Type as Trait>::{name}" ) ,
829- Applicability :: HasPlaceholders ,
830- ) ;
831- }
832- ( [ ] , [ trait_str] ) => {
833- err. span_suggestion_verbose (
834- span,
835- format ! (
836- "if there were a type named `Example` that implemented `{trait_str}`, \
837- you could use the fully-qualified path",
838- ) ,
839- format ! ( "<Example as {trait_str}>::{name}" ) ,
840- Applicability :: HasPlaceholders ,
841- ) ;
842- }
843- ( [ ] , traits) => {
844- err. span_suggestions (
845- span,
846- format ! (
847- "if there were a type named `Example` that implemented one of the \
848- traits with associated type `{name}`, you could use the \
849- fully-qualified path",
850- ) ,
851- traits. iter ( ) . map ( |trait_str| format ! ( "<Example as {trait_str}>::{name}" ) ) ,
852- Applicability :: HasPlaceholders ,
853- ) ;
854- }
855- ( [ type_str] , [ ] ) => {
856- err. span_suggestion_verbose (
857- span,
858- format ! (
859- "if there were a trait named `Example` with associated type `{name}` \
860- implemented for `{type_str}`, you could use the fully-qualified path",
861- ) ,
862- format ! ( "<{type_str} as Example>::{name}" ) ,
863- Applicability :: HasPlaceholders ,
864- ) ;
865- }
866- ( types, [ ] ) => {
867- err. span_suggestions (
868- span,
869- format ! (
870- "if there were a trait named `Example` with associated type `{name}` \
871- implemented for one of the types, you could use the fully-qualified \
872- path",
873- ) ,
874- types
875- . into_iter ( )
876- . map ( |type_str| format ! ( "<{type_str} as Example>::{name}" ) ) ,
877- Applicability :: HasPlaceholders ,
878- ) ;
879- }
880- ( types, traits) => {
881- let mut suggestions = vec ! [ ] ;
882- for type_str in types {
883- for trait_str in traits {
884- suggestions. push ( format ! ( "<{type_str} as {trait_str}>::{name}" ) ) ;
885- }
886- }
887- err. span_suggestions (
888- span,
889- "use fully-qualified syntax" ,
890- suggestions,
891- Applicability :: MachineApplicable ,
892- ) ;
893- }
894- }
895- }
896- let reported = err. emit ( ) ;
897- self . set_tainted_by_errors ( reported) ;
898- reported
899- }
900-
901792 /// Search for a trait bound on a type parameter whose trait defines the associated type given by `assoc_name`.
902793 ///
903794 /// This fails if there is no such bound in the list of candidates or if there are multiple
0 commit comments