about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2021-10-22 15:55:56 -0300
committerSantiago Pastorino <spastorino@gmail.com>2021-10-22 16:42:06 -0300
commit9e264137e9cececda98521bd411f3317c408a0ec (patch)
tree0e6b58334b320bdb5861a0f4aa2dd0a74a1f5cdb
parent132409f0c6c2a849e376ee708ee5427657178371 (diff)
downloadrust-9e264137e9cececda98521bd411f3317c408a0ec.tar.gz
rust-9e264137e9cececda98521bd411f3317c408a0ec.zip
Be sure that we do not allow too much
-rw-r--r--src/test/ui/coherence/coherence-overlap-trait-alias.rs20
-rw-r--r--src/test/ui/coherence/coherence-overlap-trait-alias.stderr16
2 files changed, 36 insertions, 0 deletions
diff --git a/src/test/ui/coherence/coherence-overlap-trait-alias.rs b/src/test/ui/coherence/coherence-overlap-trait-alias.rs
new file mode 100644
index 00000000000..45b2f086305
--- /dev/null
+++ b/src/test/ui/coherence/coherence-overlap-trait-alias.rs
@@ -0,0 +1,20 @@
+#![feature(rustc_attrs)]
+#![feature(trait_alias)]
+
+trait A {}
+trait B {}
+trait AB = A + B;
+
+impl A for u32 {}
+impl B for u32 {}
+
+trait C {}
+#[rustc_strict_coherence]
+impl<T: AB> C for T {}
+#[rustc_strict_coherence]
+impl C for u32 {}
+//~^ ERROR
+// FIXME it's giving an ungreat error but unsure if we care given that it's using an internal rustc
+// attribute and an artificial code path for testing purposes
+
+fn main() {}
diff --git a/src/test/ui/coherence/coherence-overlap-trait-alias.stderr b/src/test/ui/coherence/coherence-overlap-trait-alias.stderr
new file mode 100644
index 00000000000..e2e8ad54beb
--- /dev/null
+++ b/src/test/ui/coherence/coherence-overlap-trait-alias.stderr
@@ -0,0 +1,16 @@
+error[E0283]: type annotations needed
+  --> $DIR/coherence-overlap-trait-alias.rs:15:6
+   |
+LL | impl C for u32 {}
+   |      ^ cannot infer type for type `u32`
+   |
+   = note: cannot satisfy `u32: C`
+note: required by a bound in `C`
+  --> $DIR/coherence-overlap-trait-alias.rs:11:1
+   |
+LL | trait C {}
+   | ^^^^^^^ required by this bound in `C`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0283`.