@@ -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 ;
@@ -1403,7 +1403,7 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
14031403 fn annotate_source_of_ambiguity (
14041404 & self ,
14051405 err : & mut Diagnostic ,
1406- impls : & [ AmbiguousSelection ] ,
1406+ impls : & [ DefId ] ,
14071407 predicate : ty:: Predicate < ' tcx > ,
14081408 ) ;
14091409
@@ -2036,14 +2036,6 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
20362036 ) ;
20372037 match selcx. select_from_obligation ( & obligation) {
20382038 Err ( SelectionError :: Ambiguous ( impls) ) if impls. len ( ) > 1 => {
2039- if self . is_tainted_by_errors ( ) && subst. is_none ( ) {
2040- // If `subst.is_none()`, then this is probably two param-env
2041- // candidates or impl candidates that are equal modulo lifetimes.
2042- // Therefore, if we've already emitted an error, just skip this
2043- // one, since it's not particularly actionable.
2044- err. cancel ( ) ;
2045- return ;
2046- }
20472039 self . annotate_source_of_ambiguity ( & mut err, & impls, predicate) ;
20482040 }
20492041 _ => {
@@ -2224,35 +2216,24 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
22242216 fn annotate_source_of_ambiguity (
22252217 & self ,
22262218 err : & mut Diagnostic ,
2227- impls : & [ AmbiguousSelection ] ,
2219+ impls : & [ DefId ] ,
22282220 predicate : ty:: Predicate < ' tcx > ,
22292221 ) {
22302222 let mut spans = vec ! [ ] ;
22312223 let mut crates = vec ! [ ] ;
22322224 let mut post = vec ! [ ] ;
2233- let mut or_where_clause = false ;
2234- for ambig in impls {
2235- match ambig {
2236- AmbiguousSelection :: Impl ( def_id) => match self . tcx . span_of_impl ( * def_id) {
2237- Ok ( span) => spans. push ( span) ,
2238- Err ( name) => {
2239- crates. push ( name) ;
2240- if let Some ( header) = to_pretty_impl_header ( self . tcx , * def_id) {
2241- post. push ( header) ;
2242- }
2225+ for def_id in impls {
2226+ match self . tcx . span_of_impl ( * def_id) {
2227+ Ok ( span) => spans. push ( span) ,
2228+ Err ( name) => {
2229+ crates. push ( name) ;
2230+ if let Some ( header) = to_pretty_impl_header ( self . tcx , * def_id) {
2231+ post. push ( header) ;
22432232 }
2244- } ,
2245- AmbiguousSelection :: ParamEnv ( span) => {
2246- or_where_clause = true ;
2247- spans. push ( * span) ;
22482233 }
22492234 }
22502235 }
2251- let msg = format ! (
2252- "multiple `impl`s{} satisfying `{}` found" ,
2253- if or_where_clause { " or `where` clauses" } else { "" } ,
2254- predicate
2255- ) ;
2236+ let msg = format ! ( "multiple `impl`s satisfying `{}` found" , predicate) ;
22562237 let mut crate_names: Vec < _ > = crates. iter ( ) . map ( |n| format ! ( "`{}`" , n) ) . collect ( ) ;
22572238 crate_names. sort ( ) ;
22582239 crate_names. dedup ( ) ;
0 commit comments