@@ -23,7 +23,7 @@ use rustc_hir::GenericParam;
2323use rustc_hir:: Item ;
2424use rustc_hir:: Node ;
2525use rustc_infer:: infer:: error_reporting:: same_type_modulo_infer;
26- use rustc_infer:: traits:: { AmbiguousSelection , TraitEngine } ;
26+ use rustc_infer:: traits:: TraitEngine ;
2727use rustc_middle:: traits:: select:: OverflowError ;
2828use rustc_middle:: ty:: abstract_const:: NotConstEvaluatable ;
2929use rustc_middle:: ty:: error:: ExpectedFound ;
@@ -1402,7 +1402,7 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
14021402 fn annotate_source_of_ambiguity (
14031403 & self ,
14041404 err : & mut Diagnostic ,
1405- impls : & [ AmbiguousSelection ] ,
1405+ impls : & [ DefId ] ,
14061406 predicate : ty:: Predicate < ' tcx > ,
14071407 ) ;
14081408
@@ -2035,14 +2035,6 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
20352035 ) ;
20362036 match selcx. select_from_obligation ( & obligation) {
20372037 Err ( SelectionError :: Ambiguous ( impls) ) if impls. len ( ) > 1 => {
2038- if self . is_tainted_by_errors ( ) && subst. is_none ( ) {
2039- // If `subst.is_none()`, then this is probably two param-env
2040- // candidates or impl candidates that are equal modulo lifetimes.
2041- // Therefore, if we've already emitted an error, just skip this
2042- // one, since it's not particularly actionable.
2043- err. cancel ( ) ;
2044- return ;
2045- }
20462038 self . annotate_source_of_ambiguity ( & mut err, & impls, predicate) ;
20472039 }
20482040 _ => {
@@ -2223,35 +2215,24 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
22232215 fn annotate_source_of_ambiguity (
22242216 & self ,
22252217 err : & mut Diagnostic ,
2226- impls : & [ AmbiguousSelection ] ,
2218+ impls : & [ DefId ] ,
22272219 predicate : ty:: Predicate < ' tcx > ,
22282220 ) {
22292221 let mut spans = vec ! [ ] ;
22302222 let mut crates = vec ! [ ] ;
22312223 let mut post = vec ! [ ] ;
2232- let mut or_where_clause = false ;
2233- for ambig in impls {
2234- match ambig {
2235- AmbiguousSelection :: Impl ( def_id) => match self . tcx . span_of_impl ( * def_id) {
2236- Ok ( span) => spans. push ( span) ,
2237- Err ( name) => {
2238- crates. push ( name) ;
2239- if let Some ( header) = to_pretty_impl_header ( self . tcx , * def_id) {
2240- post. push ( header) ;
2241- }
2224+ for def_id in impls {
2225+ match self . tcx . span_of_impl ( * def_id) {
2226+ Ok ( span) => spans. push ( span) ,
2227+ Err ( name) => {
2228+ crates. push ( name) ;
2229+ if let Some ( header) = to_pretty_impl_header ( self . tcx , * def_id) {
2230+ post. push ( header) ;
22422231 }
2243- } ,
2244- AmbiguousSelection :: ParamEnv ( span) => {
2245- or_where_clause = true ;
2246- spans. push ( * span) ;
22472232 }
22482233 }
22492234 }
2250- let msg = format ! (
2251- "multiple `impl`s{} satisfying `{}` found" ,
2252- if or_where_clause { " or `where` clauses" } else { "" } ,
2253- predicate
2254- ) ;
2235+ let msg = format ! ( "multiple `impl`s satisfying `{}` found" , predicate) ;
22552236 let mut crate_names: Vec < _ > = crates. iter ( ) . map ( |n| format ! ( "`{}`" , n) ) . collect ( ) ;
22562237 crate_names. sort ( ) ;
22572238 crate_names. dedup ( ) ;
0 commit comments