about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2021-10-11 16:03:00 -0300
committerSantiago Pastorino <spastorino@gmail.com>2021-10-20 12:10:45 -0300
commit511076a102ec6e9a6d19233eeb661d60f40dd821 (patch)
tree3e4f7cc3fbc31df0150c2e407c3b966f0ccec5ae
parentab17068662e430a86b08d26d31638d59c748ba15 (diff)
downloadrust-511076a102ec6e9a6d19233eeb661d60f40dd821.tar.gz
rust-511076a102ec6e9a6d19233eeb661d60f40dd821.zip
Test that if we promise to not impl what would overlap it doesn't actually overlap
-rw-r--r--src/test/ui/coherence/auxiliary/error_lib.rs5
-rw-r--r--src/test/ui/coherence/coherence-overlap-negative-trait.rs14
2 files changed, 19 insertions, 0 deletions
diff --git a/src/test/ui/coherence/auxiliary/error_lib.rs b/src/test/ui/coherence/auxiliary/error_lib.rs
new file mode 100644
index 00000000000..43806cb995c
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/error_lib.rs
@@ -0,0 +1,5 @@
+#![crate_type = "lib"]
+#![feature(negative_impls)]
+
+pub trait Error {}
+impl !Error for &str {}
diff --git a/src/test/ui/coherence/coherence-overlap-negative-trait.rs b/src/test/ui/coherence/coherence-overlap-negative-trait.rs
new file mode 100644
index 00000000000..357c4e87c91
--- /dev/null
+++ b/src/test/ui/coherence/coherence-overlap-negative-trait.rs
@@ -0,0 +1,14 @@
+// check-pass
+// aux-build:error_lib.rs
+//
+// Check that if we promise to not impl what would overlap it doesn't actually overlap
+
+extern crate error_lib as lib;
+use lib::Error;
+
+trait From<T> {}
+
+impl From<&str> for Box<dyn Error> {}
+impl<E> From<E> for Box<dyn Error> where E: Error {}
+
+fn main() {}