Rollup merge of #118210 - lcnr:intercrate-ambiguity-causes-uwu, r=compiler-errors

intercrate ambiguity causes: ignore candidates which don't apply

r? `@compiler-errors`
This commit is contained in:
Michael Goulet 2023-11-24 07:29:11 -08:00 committed by GitHub
commit ffacd5463a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 6 deletions

View File

@ -1050,8 +1050,10 @@ fn visit_goal(&mut self, goal: &InspectGoal<'_, 'tcx>) -> ControlFlow<Self::Brea
let mut ambiguity_cause = None; let mut ambiguity_cause = None;
for cand in goal.candidates() { for cand in goal.candidates() {
// FIXME: boiiii, using string comparisions here sure is scuffed. // FIXME: boiiii, using string comparisions here sure is scuffed.
if let inspect::ProbeKind::MiscCandidate { name: "coherence unknowable", result: _ } = if let inspect::ProbeKind::MiscCandidate {
cand.kind() name: "coherence unknowable",
result: Ok(_),
} = cand.kind()
{ {
let lazily_normalize_ty = |ty: Ty<'tcx>| { let lazily_normalize_ty = |ty: Ty<'tcx>| {
let mut fulfill_cx = <dyn TraitEngine<'tcx>>::new(infcx); let mut fulfill_cx = <dyn TraitEngine<'tcx>>::new(infcx);

View File

@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `CoerceUnsized<&Wrapper<_>>` for type `&Wrapper<_>` error[E0119]: conflicting implementations of trait `CoerceUnsized<&Wrapper<_>>` for type `&Wrapper<_>`
--> $DIR/E0476.rs:9:1 --> $DIR/E0476.rs:11:1
| |
LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {} LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -9,18 +9,18 @@ LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S
where 'b: 'a, T: Unsize<U>, T: ?Sized, U: ?Sized; where 'b: 'a, T: Unsize<U>, T: ?Sized, U: ?Sized;
error[E0476]: lifetime of the source pointer does not outlive lifetime bound of the object type error[E0476]: lifetime of the source pointer does not outlive lifetime bound of the object type
--> $DIR/E0476.rs:9:1 --> $DIR/E0476.rs:11:1
| |
LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {} LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
note: object type is valid for the lifetime `'a` as defined here note: object type is valid for the lifetime `'a` as defined here
--> $DIR/E0476.rs:9:6 --> $DIR/E0476.rs:11:6
| |
LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {} LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {}
| ^^ | ^^
note: source pointer is only valid for the lifetime `'b` as defined here note: source pointer is only valid for the lifetime `'b` as defined here
--> $DIR/E0476.rs:9:10 --> $DIR/E0476.rs:11:10
| |
LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {} LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {}
| ^^ | ^^

View File

@ -0,0 +1,31 @@
error[E0119]: conflicting implementations of trait `CoerceUnsized<&Wrapper<_>>` for type `&Wrapper<_>`
--> $DIR/E0476.rs:11:1
|
LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `core`:
- impl<'a, 'b, T, U> CoerceUnsized<&'a U> for &'b T
where 'b: 'a, T: Unsize<U>, T: ?Sized, U: ?Sized;
error[E0476]: lifetime of the source pointer does not outlive lifetime bound of the object type
--> $DIR/E0476.rs:11:1
|
LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: object type is valid for the lifetime `'a` as defined here
--> $DIR/E0476.rs:11:6
|
LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {}
| ^^
note: source pointer is only valid for the lifetime `'b` as defined here
--> $DIR/E0476.rs:11:10
|
LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper<T>> for &'b Wrapper<S> where S: Unsize<T> {}
| ^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0119, E0476.
For more information about an error, try `rustc --explain E0119`.

View File

@ -1,3 +1,5 @@
// revisions: old next
//[next] compile-flags: -Ztrait-solver=next-coherence
#![feature(coerce_unsized)] #![feature(coerce_unsized)]
#![feature(unsize)] #![feature(unsize)]