@@ -23,7 +23,7 @@ use rustc_hir::GenericParam;
23
23
use rustc_hir:: Item ;
24
24
use rustc_hir:: Node ;
25
25
use rustc_infer:: infer:: error_reporting:: same_type_modulo_infer;
26
- use rustc_infer:: traits:: { AmbiguousSelection , TraitEngine } ;
26
+ use rustc_infer:: traits:: TraitEngine ;
27
27
use rustc_middle:: traits:: select:: OverflowError ;
28
28
use rustc_middle:: ty:: abstract_const:: NotConstEvaluatable ;
29
29
use rustc_middle:: ty:: error:: ExpectedFound ;
@@ -1402,7 +1402,7 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
1402
1402
fn annotate_source_of_ambiguity (
1403
1403
& self ,
1404
1404
err : & mut Diagnostic ,
1405
- impls : & [ AmbiguousSelection ] ,
1405
+ impls : & [ DefId ] ,
1406
1406
predicate : ty:: Predicate < ' tcx > ,
1407
1407
) ;
1408
1408
@@ -2035,14 +2035,6 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
2035
2035
) ;
2036
2036
match selcx. select_from_obligation ( & obligation) {
2037
2037
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
- }
2046
2038
self . annotate_source_of_ambiguity ( & mut err, & impls, predicate) ;
2047
2039
}
2048
2040
_ => {
@@ -2223,35 +2215,24 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
2223
2215
fn annotate_source_of_ambiguity (
2224
2216
& self ,
2225
2217
err : & mut Diagnostic ,
2226
- impls : & [ AmbiguousSelection ] ,
2218
+ impls : & [ DefId ] ,
2227
2219
predicate : ty:: Predicate < ' tcx > ,
2228
2220
) {
2229
2221
let mut spans = vec ! [ ] ;
2230
2222
let mut crates = vec ! [ ] ;
2231
2223
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) ;
2242
2231
}
2243
- } ,
2244
- AmbiguousSelection :: ParamEnv ( span) => {
2245
- or_where_clause = true ;
2246
- spans. push ( * span) ;
2247
2232
}
2248
2233
}
2249
2234
}
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) ;
2255
2236
let mut crate_names: Vec < _ > = crates. iter ( ) . map ( |n| format ! ( "`{}`" , n) ) . collect ( ) ;
2256
2237
crate_names. sort ( ) ;
2257
2238
crate_names. dedup ( ) ;
0 commit comments