about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-01-25 05:51:12 +0100
committerGitHub <noreply@github.com>2022-01-25 05:51:12 +0100
commit3d6f276ca71060a189fdbcb61b93750c2cb8c5a7 (patch)
tree7b24930eb1022d56d387f25502e21cc2e7f09055 /src/test
parent677126cac0d59c44d7448cc1e41b1e855380c6b3 (diff)
parent8189bac9636930155768150886e28e221523d6ac (diff)
downloadrust-3d6f276ca71060a189fdbcb61b93750c2cb8c5a7.tar.gz
rust-3d6f276ca71060a189fdbcb61b93750c2cb8c5a7.zip
Rollup merge of #93175 - spastorino:negative-traits-coherence-new, r=nikomatsakis
Implement stable overlap check considering negative traits

This PR implement the new disjointness rules for overlap check described in https://rust-lang.github.io/negative-impls-initiative/explainer/coherence-check.html#new-disjointness-rules

r? ``@nikomatsakis``
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/coherence/auxiliary/option_future.rs8
-rw-r--r--src/test/ui/coherence/coherence-overlap-negative-trait2.rs18
2 files changed, 26 insertions, 0 deletions
diff --git a/src/test/ui/coherence/auxiliary/option_future.rs b/src/test/ui/coherence/auxiliary/option_future.rs
new file mode 100644
index 00000000000..f71df1b87fc
--- /dev/null
+++ b/src/test/ui/coherence/auxiliary/option_future.rs
@@ -0,0 +1,8 @@
+#![crate_type = "lib"]
+#![feature(negative_impls)]
+#![feature(rustc_attrs)]
+
+pub trait Future {}
+
+#[rustc_with_negative_coherence]
+impl<E> !Future for Option<E> where E: Sized {}
diff --git a/src/test/ui/coherence/coherence-overlap-negative-trait2.rs b/src/test/ui/coherence/coherence-overlap-negative-trait2.rs
new file mode 100644
index 00000000000..1f47b5ba46e
--- /dev/null
+++ b/src/test/ui/coherence/coherence-overlap-negative-trait2.rs
@@ -0,0 +1,18 @@
+// check-pass
+// aux-build:option_future.rs
+//
+// Check that if we promise to not impl what would overlap it doesn't actually overlap
+
+#![feature(rustc_attrs)]
+
+extern crate option_future as lib;
+use lib::Future;
+
+trait Termination {}
+
+#[rustc_with_negative_coherence]
+impl<E> Termination for Option<E> where E: Sized {}
+#[rustc_with_negative_coherence]
+impl<F> Termination for F where F: Future + Sized {}
+
+fn main() {}