From d51ef5c1afc6491d9c224e12cc5c1e72a58bf81a Mon Sep 17 00:00:00 2001 From: lcnr Date: Thu, 23 Nov 2023 12:25:41 +0000 Subject: [PATCH] fix intercrate ambiguity causes --- .../src/traits/coherence.rs | 6 ++-- .../{E0476.stderr => E0476.next.stderr} | 8 ++--- tests/ui/error-codes/E0476.old.stderr | 31 +++++++++++++++++++ tests/ui/error-codes/E0476.rs | 2 ++ 4 files changed, 41 insertions(+), 6 deletions(-) rename tests/ui/error-codes/{E0476.stderr => E0476.next.stderr} (92%) create mode 100644 tests/ui/error-codes/E0476.old.stderr diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 9119792e32439..f3993ec256676 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -1050,8 +1050,10 @@ impl<'a, 'tcx> ProofTreeVisitor<'tcx> for AmbiguityCausesVisitor<'a> { let mut ambiguity_cause = None; for cand in goal.candidates() { // FIXME: boiiii, using string comparisions here sure is scuffed. - if let inspect::ProbeKind::MiscCandidate { name: "coherence unknowable", result: _ } = - cand.kind() + if let inspect::ProbeKind::MiscCandidate { + name: "coherence unknowable", + result: Ok(_), + } = cand.kind() { let lazily_normalize_ty = |ty: Ty<'tcx>| { let mut fulfill_cx = >::new(infcx); diff --git a/tests/ui/error-codes/E0476.stderr b/tests/ui/error-codes/E0476.next.stderr similarity index 92% rename from tests/ui/error-codes/E0476.stderr rename to tests/ui/error-codes/E0476.next.stderr index 0378ac6e8ec91..454dbecc7d01f 100644 --- a/tests/ui/error-codes/E0476.stderr +++ b/tests/ui/error-codes/E0476.next.stderr @@ -1,5 +1,5 @@ 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> for &'b Wrapper where S: Unsize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -9,18 +9,18 @@ LL | impl<'a, 'b, T, S> CoerceUnsized<&'a Wrapper> for &'b Wrapper where S where 'b: 'a, T: Unsize, T: ?Sized, U: ?Sized; 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> for &'b Wrapper where S: Unsize {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 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> for &'b Wrapper where S: Unsize {} | ^^ 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> for &'b Wrapper where S: Unsize {} | ^^ diff --git a/tests/ui/error-codes/E0476.old.stderr b/tests/ui/error-codes/E0476.old.stderr new file mode 100644 index 0000000000000..454dbecc7d01f --- /dev/null +++ b/tests/ui/error-codes/E0476.old.stderr @@ -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> for &'b Wrapper where S: Unsize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl<'a, 'b, T, U> CoerceUnsized<&'a U> for &'b T + where 'b: 'a, T: Unsize, 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> for &'b Wrapper where S: Unsize {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +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> for &'b Wrapper where S: Unsize {} + | ^^ +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> for &'b Wrapper where S: Unsize {} + | ^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0119, E0476. +For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/error-codes/E0476.rs b/tests/ui/error-codes/E0476.rs index d5e4b8d237274..e9afc7567260f 100644 --- a/tests/ui/error-codes/E0476.rs +++ b/tests/ui/error-codes/E0476.rs @@ -1,3 +1,5 @@ +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next-coherence #![feature(coerce_unsized)] #![feature(unsize)]