Skip to content

Commit ecb0a11

Browse files
committed
Revert "Fix #90970, doesn't address #87437"
This reverts commit ac8cbbd.
1 parent 3e15b92 commit ecb0a11

File tree

8 files changed

+6
-115
lines changed

8 files changed

+6
-115
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+6-73
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ pub mod on_unimplemented;
22
pub mod suggestions;
33

44
use super::{
5-
DerivedObligationCause, EvaluationResult, FulfillmentContext, FulfillmentError,
6-
FulfillmentErrorCode, ImplDerivedObligationCause, MismatchedProjectionTypes, Obligation,
7-
ObligationCause, ObligationCauseCode, OnUnimplementedDirective, OnUnimplementedNote,
8-
OutputTypeParameterMismatch, Overflow, PredicateObligation, SelectionContext, SelectionError,
9-
TraitNotObjectSafe,
5+
EvaluationResult, FulfillmentContext, FulfillmentError, FulfillmentErrorCode,
6+
MismatchedProjectionTypes, Obligation, ObligationCause, ObligationCauseCode,
7+
OnUnimplementedDirective, OnUnimplementedNote, OutputTypeParameterMismatch, Overflow,
8+
PredicateObligation, SelectionContext, SelectionError, TraitNotObjectSafe,
109
};
1110

1211
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
@@ -661,77 +660,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
661660
} else if !suggested {
662661
// Can't show anything else useful, try to find similar impls.
663662
let impl_candidates = self.find_similar_impl_candidates(trait_ref);
664-
if !self.report_similar_impl_candidates(
663+
self.report_similar_impl_candidates(
665664
impl_candidates,
666665
trait_ref,
667666
&mut err,
668-
) {
669-
// This is *almost* equivalent to
670-
// `obligation.cause.code().peel_derives()`, but it gives us the
671-
// trait predicate for that corresponding root obligation. This
672-
// lets us get a derived obligation from a type parameter, like
673-
// when calling `string.strip_suffix(p)` where `p` is *not* an
674-
// implementer of `Pattern<'_>`.
675-
let mut code = obligation.cause.code();
676-
let mut trait_pred = trait_predicate;
677-
let mut peeled = false;
678-
loop {
679-
match &*code {
680-
ObligationCauseCode::FunctionArgumentObligation {
681-
parent_code,
682-
..
683-
} => {
684-
code = &parent_code;
685-
}
686-
ObligationCauseCode::ImplDerivedObligation(
687-
box ImplDerivedObligationCause {
688-
derived:
689-
DerivedObligationCause {
690-
parent_code,
691-
parent_trait_pred,
692-
},
693-
..
694-
},
695-
)
696-
| ObligationCauseCode::BuiltinDerivedObligation(
697-
DerivedObligationCause {
698-
parent_code,
699-
parent_trait_pred,
700-
},
701-
)
702-
| ObligationCauseCode::DerivedObligation(
703-
DerivedObligationCause {
704-
parent_code,
705-
parent_trait_pred,
706-
},
707-
) => {
708-
peeled = true;
709-
code = &parent_code;
710-
trait_pred = *parent_trait_pred;
711-
}
712-
_ => break,
713-
};
714-
}
715-
let def_id = trait_pred.def_id();
716-
// Mention *all* the `impl`s for the *top most* obligation, the
717-
// user might have meant to use one of them, if any found. We skip
718-
// auto-traits or fundamental traits that might not be exactly what
719-
// the user might expect to be presented with. Instead this is
720-
// useful for less general traits.
721-
if peeled
722-
&& !self.tcx.trait_is_auto(def_id)
723-
&& !self.tcx.lang_items().items().contains(&Some(def_id))
724-
{
725-
let trait_ref = trait_pred.to_poly_trait_ref();
726-
let impl_candidates =
727-
self.find_similar_impl_candidates(trait_ref);
728-
self.report_similar_impl_candidates(
729-
impl_candidates,
730-
trait_ref,
731-
&mut err,
732-
);
733-
}
734-
}
667+
);
735668
}
736669

737670
// Changing mutability doesn't make a difference to whether we have

src/test/ui/const-generics/generic_const_exprs/issue-85848.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ LL | writes_to_specific_path(&cap);
66
| |
77
| required by a bound introduced by this call
88
|
9-
= help: the trait `Delegates<U>` is implemented for `T`
109
note: required because of the requirements on the impl of `Contains<(), true>` for `&C`
1110
--> $DIR/issue-85848.rs:21:12
1211
|

src/test/ui/impl-trait/cross-return-site-inference.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LL | Err("whoops")?;
77
| ^ the trait `From<&str>` is not implemented for `impl Debug`
88
|
99
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
10-
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
1110
= note: required because of the requirements on the impl of `FromResidual<Result<Infallible, &str>>` for `Result<(), impl Debug>`
1211

1312
error[E0277]: the trait bound `impl Debug: From<&str>` is not satisfied

src/test/ui/impl-trait/nested_impl_trait.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfie
5252
LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
5353
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug`
5454
|
55-
= help: the trait `Into<U>` is implemented for `T`
5655
= note: required because of the requirements on the impl of `Into<impl Debug>` for `impl Into<u32>`
5756

5857
error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
@@ -61,7 +60,6 @@ error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfie
6160
LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
6261
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug`
6362
|
64-
= help: the trait `Into<U>` is implemented for `T`
6563
= note: required because of the requirements on the impl of `Into<impl Debug>` for `impl Into<u32>`
6664

6765
error: aborting due to 8 previous errors

src/test/ui/issues/issue-32709.stderr

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ LL | Err(5)?;
77
| ^ the trait `From<{integer}>` is not implemented for `()`
88
|
99
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
10-
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
1110
= note: required because of the requirements on the impl of `FromResidual<Result<Infallible, {integer}>>` for `Result<i32, ()>`
1211

1312
error: aborting due to previous error

src/test/ui/kindck/kindck-impl-type-params.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ error[E0277]: the trait bound `String: Copy` is not satisfied
8080
LL | let a = t as Box<dyn Gettable<String>>;
8181
| ^ the trait `Copy` is not implemented for `String`
8282
|
83-
= help: the trait `Gettable<T>` is implemented for `S<T>`
8483
note: required because of the requirements on the impl of `Gettable<String>` for `S<String>`
8584
--> $DIR/kindck-impl-type-params.rs:14:32
8685
|
@@ -94,7 +93,6 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied
9493
LL | let a: Box<dyn Gettable<Foo>> = t;
9594
| ^ the trait `Copy` is not implemented for `Foo`
9695
|
97-
= help: the trait `Gettable<T>` is implemented for `S<T>`
9896
note: required because of the requirements on the impl of `Gettable<Foo>` for `S<Foo>`
9997
--> $DIR/kindck-impl-type-params.rs:14:32
10098
|

src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs

-12
This file was deleted.

src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr

-23
This file was deleted.

0 commit comments

Comments
 (0)