From e1edefc137a25e50ab42eb38b7456aa5652538f8 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 2 Aug 2023 02:06:55 +0000 Subject: [PATCH] coherence doesn't like region constraints --- .../coherence-negative-outlives-lifetimes.rs | 2 +- ...outlives-lifetimes.with_negative_coherence.stderr | 11 +++++++++++ tests/ui/coherence/coherence-overlap-with-regions.rs | 2 +- .../coherence/coherence-overlap-with-regions.stderr | 11 +++++++++++ .../negative-coherence-considering-regions.rs | 2 +- ...ve-coherence-considering-regions.static_lt.stderr | 12 ++++++++++++ 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 tests/ui/coherence/coherence-negative-outlives-lifetimes.with_negative_coherence.stderr create mode 100644 tests/ui/coherence/coherence-overlap-with-regions.stderr create mode 100644 tests/ui/coherence/negative-coherence-considering-regions.static_lt.stderr diff --git a/tests/ui/coherence/coherence-negative-outlives-lifetimes.rs b/tests/ui/coherence/coherence-negative-outlives-lifetimes.rs index 3acf0d8d39ab9..0e16d12a18114 100644 --- a/tests/ui/coherence/coherence-negative-outlives-lifetimes.rs +++ b/tests/ui/coherence/coherence-negative-outlives-lifetimes.rs @@ -1,5 +1,5 @@ // revisions: stock with_negative_coherence -//[with_negative_coherence] check-pass +//[with_negative_coherence] known-bug: unknown #![feature(negative_impls)] #![cfg_attr(with_negative_coherence, feature(with_negative_coherence))] diff --git a/tests/ui/coherence/coherence-negative-outlives-lifetimes.with_negative_coherence.stderr b/tests/ui/coherence/coherence-negative-outlives-lifetimes.with_negative_coherence.stderr new file mode 100644 index 0000000000000..097cc4e0fe3e6 --- /dev/null +++ b/tests/ui/coherence/coherence-negative-outlives-lifetimes.with_negative_coherence.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `MyTrait<'_>` for type `&_` + --> $DIR/coherence-negative-outlives-lifetimes.rs:14:1 + | +LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {} + | ---------------------------------------------- first implementation here +LL | impl<'a, T> MyTrait<'a> for &'a T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/coherence/coherence-overlap-with-regions.rs b/tests/ui/coherence/coherence-overlap-with-regions.rs index 32f01f4180103..9f237986acfa0 100644 --- a/tests/ui/coherence/coherence-overlap-with-regions.rs +++ b/tests/ui/coherence/coherence-overlap-with-regions.rs @@ -1,4 +1,4 @@ -// check-pass +// known-bug: unknown #![feature(negative_impls)] #![feature(rustc_attrs)] diff --git a/tests/ui/coherence/coherence-overlap-with-regions.stderr b/tests/ui/coherence/coherence-overlap-with-regions.stderr new file mode 100644 index 0000000000000..fd25f0978bad2 --- /dev/null +++ b/tests/ui/coherence/coherence-overlap-with-regions.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `Bar` for type `&_` + --> $DIR/coherence-overlap-with-regions.rs:20:1 + | +LL | impl Bar for T {} + | ---------------------- first implementation here +LL | impl Bar for &T where T: 'static {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/coherence/negative-coherence-considering-regions.rs b/tests/ui/coherence/negative-coherence-considering-regions.rs index a43ad19eca7c0..167c7fa211fe4 100644 --- a/tests/ui/coherence/negative-coherence-considering-regions.rs +++ b/tests/ui/coherence/negative-coherence-considering-regions.rs @@ -1,5 +1,5 @@ // revisions: any_lt static_lt -//[static_lt] check-pass +//[static_lt] known-bug: unknown #![feature(negative_impls)] #![feature(with_negative_coherence)] diff --git a/tests/ui/coherence/negative-coherence-considering-regions.static_lt.stderr b/tests/ui/coherence/negative-coherence-considering-regions.static_lt.stderr new file mode 100644 index 0000000000000..87e7be2aa44a9 --- /dev/null +++ b/tests/ui/coherence/negative-coherence-considering-regions.static_lt.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Bar` for type `&'static _` + --> $DIR/negative-coherence-considering-regions.rs:26:1 + | +LL | impl Bar for T where T: Foo {} + | ------------------------------ first implementation here +... +LL | impl Bar for &'static T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&'static _` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`.