about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2021-10-22 17:54:20 -0300
committerSantiago Pastorino <spastorino@gmail.com>2021-10-22 17:54:20 -0300
commit953418685769424388fb9ea1f4b2beaceedb6857 (patch)
tree9c25a6391ff62954512b16744c54d24c7237b6b4 /src/test/ui
parent9e264137e9cececda98521bd411f3317c408a0ec (diff)
downloadrust-953418685769424388fb9ea1f4b2beaceedb6857.tar.gz
rust-953418685769424388fb9ea1f4b2beaceedb6857.zip
Hide negative coherence checks under negative_impls feature flag
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/coherence/coherence-overlap-negate-not-use-feature-gate.rs8
-rw-r--r--src/test/ui/coherence/coherence-overlap-negate-not-use-feature-gate.stderr11
-rw-r--r--src/test/ui/coherence/coherence-overlap-negate-use-feature-gate.rs11
-rw-r--r--src/test/ui/coherence/coherence-overlap-negative-trait.rs2
4 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/coherence/coherence-overlap-negate-not-use-feature-gate.rs b/src/test/ui/coherence/coherence-overlap-negate-not-use-feature-gate.rs
new file mode 100644
index 00000000000..a067736f63a
--- /dev/null
+++ b/src/test/ui/coherence/coherence-overlap-negate-not-use-feature-gate.rs
@@ -0,0 +1,8 @@
+use std::ops::DerefMut;
+
+trait Foo {}
+impl<T: DerefMut> Foo for T {}
+impl<U> Foo for &U {}
+//~^ ERROR: conflicting implementations of trait `Foo` for type `&_` [E0119]
+
+fn main() {}
diff --git a/src/test/ui/coherence/coherence-overlap-negate-not-use-feature-gate.stderr b/src/test/ui/coherence/coherence-overlap-negate-not-use-feature-gate.stderr
new file mode 100644
index 00000000000..4b55001ecc0
--- /dev/null
+++ b/src/test/ui/coherence/coherence-overlap-negate-not-use-feature-gate.stderr
@@ -0,0 +1,11 @@
+error[E0119]: conflicting implementations of trait `Foo` for type `&_`
+  --> $DIR/coherence-overlap-negate-not-use-feature-gate.rs:5:1
+   |
+LL | impl<T: DerefMut> Foo for T {}
+   | --------------------------- first implementation here
+LL | impl<U> Foo for &U {}
+   | ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.
diff --git a/src/test/ui/coherence/coherence-overlap-negate-use-feature-gate.rs b/src/test/ui/coherence/coherence-overlap-negate-use-feature-gate.rs
new file mode 100644
index 00000000000..e024eae9819
--- /dev/null
+++ b/src/test/ui/coherence/coherence-overlap-negate-use-feature-gate.rs
@@ -0,0 +1,11 @@
+// check-pass
+
+#![feature(negative_impls)]
+
+use std::ops::DerefMut;
+
+trait Foo {}
+impl<T: DerefMut> Foo for T {}
+impl<U> Foo for &U {}
+
+fn main() {}
diff --git a/src/test/ui/coherence/coherence-overlap-negative-trait.rs b/src/test/ui/coherence/coherence-overlap-negative-trait.rs
index 357c4e87c91..ab65163bea4 100644
--- a/src/test/ui/coherence/coherence-overlap-negative-trait.rs
+++ b/src/test/ui/coherence/coherence-overlap-negative-trait.rs
@@ -3,6 +3,8 @@
 //
 // Check that if we promise to not impl what would overlap it doesn't actually overlap
 
+#![feature(negative_impls)]
+
 extern crate error_lib as lib;
 use lib::Error;