@@ -815,118 +815,6 @@ impl<'o, 'tcx> dyn HirTyLowerer<'tcx> + 'o {
815815 }
816816 }
817817
818- fn report_ambiguous_assoc_type (
819- & self ,
820- span : Span ,
821- types : & [ String ] ,
822- traits : & [ String ] ,
823- name : Symbol ,
824- ) -> ErrorGuaranteed {
825- let mut err =
826- struct_span_code_err ! ( self . tcx( ) . dcx( ) , span, E0223 , "ambiguous associated type" ) ;
827- if self
828- . tcx ( )
829- . resolutions ( ( ) )
830- . confused_type_with_std_module
831- . keys ( )
832- . any ( |full_span| full_span. contains ( span) )
833- {
834- err. span_suggestion_verbose (
835- span. shrink_to_lo ( ) ,
836- "you are looking for the module in `std`, not the primitive type" ,
837- "std::" ,
838- Applicability :: MachineApplicable ,
839- ) ;
840- } else {
841- let mut types = types. to_vec ( ) ;
842- types. sort ( ) ;
843- let mut traits = traits. to_vec ( ) ;
844- traits. sort ( ) ;
845- match ( & types[ ..] , & traits[ ..] ) {
846- ( [ ] , [ ] ) => {
847- err. span_suggestion_verbose (
848- span,
849- format ! (
850- "if there were a type named `Type` that implements a trait named \
851- `Trait` with associated type `{name}`, you could use the \
852- fully-qualified path",
853- ) ,
854- format ! ( "<Type as Trait>::{name}" ) ,
855- Applicability :: HasPlaceholders ,
856- ) ;
857- }
858- ( [ ] , [ trait_str] ) => {
859- err. span_suggestion_verbose (
860- span,
861- format ! (
862- "if there were a type named `Example` that implemented `{trait_str}`, \
863- you could use the fully-qualified path",
864- ) ,
865- format ! ( "<Example as {trait_str}>::{name}" ) ,
866- Applicability :: HasPlaceholders ,
867- ) ;
868- }
869- ( [ ] , traits) => {
870- err. span_suggestions (
871- span,
872- format ! (
873- "if there were a type named `Example` that implemented one of the \
874- traits with associated type `{name}`, you could use the \
875- fully-qualified path",
876- ) ,
877- traits
878- . iter ( )
879- . map ( |trait_str| format ! ( "<Example as {trait_str}>::{name}" ) )
880- . collect :: < Vec < _ > > ( ) ,
881- Applicability :: HasPlaceholders ,
882- ) ;
883- }
884- ( [ type_str] , [ ] ) => {
885- err. span_suggestion_verbose (
886- span,
887- format ! (
888- "if there were a trait named `Example` with associated type `{name}` \
889- implemented for `{type_str}`, you could use the fully-qualified path",
890- ) ,
891- format ! ( "<{type_str} as Example>::{name}" ) ,
892- Applicability :: HasPlaceholders ,
893- ) ;
894- }
895- ( types, [ ] ) => {
896- err. span_suggestions (
897- span,
898- format ! (
899- "if there were a trait named `Example` with associated type `{name}` \
900- implemented for one of the types, you could use the fully-qualified \
901- path",
902- ) ,
903- types
904- . into_iter ( )
905- . map ( |type_str| format ! ( "<{type_str} as Example>::{name}" ) ) ,
906- Applicability :: HasPlaceholders ,
907- ) ;
908- }
909- ( types, traits) => {
910- let mut suggestions = vec ! [ ] ;
911- for type_str in types {
912- for trait_str in traits {
913- suggestions. push ( format ! ( "<{type_str} as {trait_str}>::{name}" ) ) ;
914- }
915- }
916- err. span_suggestions (
917- span,
918- "use fully-qualified syntax" ,
919- suggestions,
920- Applicability :: MachineApplicable ,
921- ) ;
922- }
923- }
924- }
925- let reported = err. emit ( ) ;
926- self . set_tainted_by_errors ( reported) ;
927- reported
928- }
929-
930818 /// Search for a bound on a type parameter which includes the associated item given by `assoc_name`.
931819 ///
932820 /// `ty_param_def_id` is the `DefId` of the type parameter.
0 commit comments