Skip to content

Commit

Permalink
Revert "Fix rust-lang#90970, doesn't address rust-lang#87437"
Browse files Browse the repository at this point in the history
This reverts commit ac8cbbd.
  • Loading branch information
Dylan-DPC committed Apr 5, 2022
1 parent 3e15b92 commit ecb0a11
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 115 deletions.
79 changes: 6 additions & 73 deletions compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ pub mod on_unimplemented;
pub mod suggestions;

use super::{
DerivedObligationCause, EvaluationResult, FulfillmentContext, FulfillmentError,
FulfillmentErrorCode, ImplDerivedObligationCause, MismatchedProjectionTypes, Obligation,
ObligationCause, ObligationCauseCode, OnUnimplementedDirective, OnUnimplementedNote,
OutputTypeParameterMismatch, Overflow, PredicateObligation, SelectionContext, SelectionError,
TraitNotObjectSafe,
EvaluationResult, FulfillmentContext, FulfillmentError, FulfillmentErrorCode,
MismatchedProjectionTypes, Obligation, ObligationCause, ObligationCauseCode,
OnUnimplementedDirective, OnUnimplementedNote, OutputTypeParameterMismatch, Overflow,
PredicateObligation, SelectionContext, SelectionError, TraitNotObjectSafe,
};

use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
Expand Down Expand Up @@ -661,77 +660,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
} else if !suggested {
// Can't show anything else useful, try to find similar impls.
let impl_candidates = self.find_similar_impl_candidates(trait_ref);
if !self.report_similar_impl_candidates(
self.report_similar_impl_candidates(
impl_candidates,
trait_ref,
&mut err,
) {
// This is *almost* equivalent to
// `obligation.cause.code().peel_derives()`, but it gives us the
// trait predicate for that corresponding root obligation. This
// lets us get a derived obligation from a type parameter, like
// when calling `string.strip_suffix(p)` where `p` is *not* an
// implementer of `Pattern<'_>`.
let mut code = obligation.cause.code();
let mut trait_pred = trait_predicate;
let mut peeled = false;
loop {
match &*code {
ObligationCauseCode::FunctionArgumentObligation {
parent_code,
..
} => {
code = &parent_code;
}
ObligationCauseCode::ImplDerivedObligation(
box ImplDerivedObligationCause {
derived:
DerivedObligationCause {
parent_code,
parent_trait_pred,
},
..
},
)
| ObligationCauseCode::BuiltinDerivedObligation(
DerivedObligationCause {
parent_code,
parent_trait_pred,
},
)
| ObligationCauseCode::DerivedObligation(
DerivedObligationCause {
parent_code,
parent_trait_pred,
},
) => {
peeled = true;
code = &parent_code;
trait_pred = *parent_trait_pred;
}
_ => break,
};
}
let def_id = trait_pred.def_id();
// Mention *all* the `impl`s for the *top most* obligation, the
// user might have meant to use one of them, if any found. We skip
// auto-traits or fundamental traits that might not be exactly what
// the user might expect to be presented with. Instead this is
// useful for less general traits.
if peeled
&& !self.tcx.trait_is_auto(def_id)
&& !self.tcx.lang_items().items().contains(&Some(def_id))
{
let trait_ref = trait_pred.to_poly_trait_ref();
let impl_candidates =
self.find_similar_impl_candidates(trait_ref);
self.report_similar_impl_candidates(
impl_candidates,
trait_ref,
&mut err,
);
}
}
);
}

// Changing mutability doesn't make a difference to whether we have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ LL | writes_to_specific_path(&cap);
| |
| required by a bound introduced by this call
|
= help: the trait `Delegates<U>` is implemented for `T`
note: required because of the requirements on the impl of `Contains<(), true>` for `&C`
--> $DIR/issue-85848.rs:21:12
|
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/impl-trait/cross-return-site-inference.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LL | Err("whoops")?;
| ^ the trait `From<&str>` is not implemented for `impl Debug`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
= note: required because of the requirements on the impl of `FromResidual<Result<Infallible, &str>>` for `Result<(), impl Debug>`

error[E0277]: the trait bound `impl Debug: From<&str>` is not satisfied
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/impl-trait/nested_impl_trait.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfie
LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug`
|
= help: the trait `Into<U>` is implemented for `T`
= note: required because of the requirements on the impl of `Into<impl Debug>` for `impl Into<u32>`

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

error: aborting due to 8 previous errors
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/issues/issue-32709.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ LL | Err(5)?;
| ^ the trait `From<{integer}>` is not implemented for `()`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
= note: required because of the requirements on the impl of `FromResidual<Result<Infallible, {integer}>>` for `Result<i32, ()>`

error: aborting due to previous error
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/kindck/kindck-impl-type-params.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ error[E0277]: the trait bound `String: Copy` is not satisfied
LL | let a = t as Box<dyn Gettable<String>>;
| ^ the trait `Copy` is not implemented for `String`
|
= help: the trait `Gettable<T>` is implemented for `S<T>`
note: required because of the requirements on the impl of `Gettable<String>` for `S<String>`
--> $DIR/kindck-impl-type-params.rs:14:32
|
Expand All @@ -94,7 +93,6 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied
LL | let a: Box<dyn Gettable<Foo>> = t;
| ^ the trait `Copy` is not implemented for `Foo`
|
= help: the trait `Gettable<T>` is implemented for `S<T>`
note: required because of the requirements on the impl of `Gettable<Foo>` for `S<Foo>`
--> $DIR/kindck-impl-type-params.rs:14:32
|
Expand Down
12 changes: 0 additions & 12 deletions src/test/ui/traits/bound/assoc-fn-bound-root-obligation.rs

This file was deleted.

23 changes: 0 additions & 23 deletions src/test/ui/traits/bound/assoc-fn-bound-root-obligation.stderr

This file was deleted.

0 comments on commit ecb0a11

Please sign in to comment.