summaryrefslogtreecommitdiffstats
path: root/tests/ui/marker_trait_attr
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/marker_trait_attr
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/marker_trait_attr')
-rw-r--r--tests/ui/marker_trait_attr/issue-61651-type-mismatch.rs17
-rw-r--r--tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs23
-rw-r--r--tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr52
-rw-r--r--tests/ui/marker_trait_attr/marker-attribute-with-values.rs12
-rw-r--r--tests/ui/marker_trait_attr/marker-attribute-with-values.stderr20
-rw-r--r--tests/ui/marker_trait_attr/marker-trait-with-associated-items.rs40
-rw-r--r--tests/ui/marker_trait_attr/marker-trait-with-associated-items.stderr39
-rw-r--r--tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.rs20
-rw-r--r--tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.stderr12
-rw-r--r--tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs10
-rw-r--r--tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.rs9
-rw-r--r--tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr31
-rw-r--r--tests/ui/marker_trait_attr/overlap-marker-trait.rs29
-rw-r--r--tests/ui/marker_trait_attr/overlap-marker-trait.stderr15
-rw-r--r--tests/ui/marker_trait_attr/overlap-permitted-for-annotated-marker-traits.rs27
-rw-r--r--tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs9
-rw-r--r--tests/ui/marker_trait_attr/override-item-on-marker-trait.rs23
-rw-r--r--tests/ui/marker_trait_attr/override-item-on-marker-trait.stderr15
-rw-r--r--tests/ui/marker_trait_attr/region-overlap.rs8
-rw-r--r--tests/ui/marker_trait_attr/region-overlap.stderr31
-rw-r--r--tests/ui/marker_trait_attr/unsound-overlap.rs25
-rw-r--r--tests/ui/marker_trait_attr/unsound-overlap.stderr12
22 files changed, 479 insertions, 0 deletions
diff --git a/tests/ui/marker_trait_attr/issue-61651-type-mismatch.rs b/tests/ui/marker_trait_attr/issue-61651-type-mismatch.rs
new file mode 100644
index 000000000..0af706615
--- /dev/null
+++ b/tests/ui/marker_trait_attr/issue-61651-type-mismatch.rs
@@ -0,0 +1,17 @@
+// check-pass
+// Regression test for issue #61651
+// Verifies that we don't try to constrain inference
+// variables due to the presence of multiple applicable
+// marker trait impls
+
+#![feature(marker_trait_attr)]
+
+#[marker] // Remove this line and it works?!?
+trait Foo<T> {}
+impl Foo<u16> for u8 {}
+impl Foo<[u8; 1]> for u8 {}
+fn foo<T: Foo<U>, U>(_: T) -> U { unimplemented!() }
+
+fn main() {
+ let _: u16 = foo(0_u8);
+}
diff --git a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs
new file mode 100644
index 000000000..0bf620934
--- /dev/null
+++ b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs
@@ -0,0 +1,23 @@
+#![feature(marker_trait_attr)]
+
+#[marker] //~ ERROR attribute should be applied to a trait
+struct Struct {}
+
+#[marker] //~ ERROR attribute should be applied to a trait
+impl Struct {}
+
+#[marker] //~ ERROR attribute should be applied to a trait
+union Union {
+ x: i32,
+}
+
+#[marker] //~ ERROR attribute should be applied to a trait
+const CONST: usize = 10;
+
+#[marker] //~ ERROR attribute should be applied to a trait
+fn function() {}
+
+#[marker] //~ ERROR attribute should be applied to a trait
+type Type = ();
+
+fn main() {}
diff --git a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr
new file mode 100644
index 000000000..19a5290dd
--- /dev/null
+++ b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr
@@ -0,0 +1,52 @@
+error: attribute should be applied to a trait
+ --> $DIR/marker-attribute-on-non-trait.rs:3:1
+ |
+LL | #[marker]
+ | ^^^^^^^^^
+LL | struct Struct {}
+ | ---------------- not a trait
+
+error: attribute should be applied to a trait
+ --> $DIR/marker-attribute-on-non-trait.rs:6:1
+ |
+LL | #[marker]
+ | ^^^^^^^^^
+LL | impl Struct {}
+ | -------------- not a trait
+
+error: attribute should be applied to a trait
+ --> $DIR/marker-attribute-on-non-trait.rs:9:1
+ |
+LL | #[marker]
+ | ^^^^^^^^^
+LL | / union Union {
+LL | | x: i32,
+LL | | }
+ | |_- not a trait
+
+error: attribute should be applied to a trait
+ --> $DIR/marker-attribute-on-non-trait.rs:14:1
+ |
+LL | #[marker]
+ | ^^^^^^^^^
+LL | const CONST: usize = 10;
+ | ------------------------ not a trait
+
+error: attribute should be applied to a trait
+ --> $DIR/marker-attribute-on-non-trait.rs:17:1
+ |
+LL | #[marker]
+ | ^^^^^^^^^
+LL | fn function() {}
+ | ---------------- not a trait
+
+error: attribute should be applied to a trait
+ --> $DIR/marker-attribute-on-non-trait.rs:20:1
+ |
+LL | #[marker]
+ | ^^^^^^^^^
+LL | type Type = ();
+ | --------------- not a trait
+
+error: aborting due to 6 previous errors
+
diff --git a/tests/ui/marker_trait_attr/marker-attribute-with-values.rs b/tests/ui/marker_trait_attr/marker-attribute-with-values.rs
new file mode 100644
index 000000000..9e07f0eae
--- /dev/null
+++ b/tests/ui/marker_trait_attr/marker-attribute-with-values.rs
@@ -0,0 +1,12 @@
+#![feature(marker_trait_attr)]
+
+#[marker(always)] //~ ERROR malformed `marker` attribute
+trait Marker1 {}
+
+#[marker("never")] //~ ERROR malformed `marker` attribute
+trait Marker2 {}
+
+#[marker(key = "value")] //~ ERROR malformed `marker` attribute
+trait Marker3 {}
+
+fn main() {}
diff --git a/tests/ui/marker_trait_attr/marker-attribute-with-values.stderr b/tests/ui/marker_trait_attr/marker-attribute-with-values.stderr
new file mode 100644
index 000000000..6f9c9508e
--- /dev/null
+++ b/tests/ui/marker_trait_attr/marker-attribute-with-values.stderr
@@ -0,0 +1,20 @@
+error: malformed `marker` attribute input
+ --> $DIR/marker-attribute-with-values.rs:3:1
+ |
+LL | #[marker(always)]
+ | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[marker]`
+
+error: malformed `marker` attribute input
+ --> $DIR/marker-attribute-with-values.rs:6:1
+ |
+LL | #[marker("never")]
+ | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[marker]`
+
+error: malformed `marker` attribute input
+ --> $DIR/marker-attribute-with-values.rs:9:1
+ |
+LL | #[marker(key = "value")]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[marker]`
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/marker_trait_attr/marker-trait-with-associated-items.rs b/tests/ui/marker_trait_attr/marker-trait-with-associated-items.rs
new file mode 100644
index 000000000..a6e00ecc9
--- /dev/null
+++ b/tests/ui/marker_trait_attr/marker-trait-with-associated-items.rs
@@ -0,0 +1,40 @@
+#![feature(marker_trait_attr)]
+#![feature(associated_type_defaults)]
+
+#[marker]
+trait MarkerConst {
+ const N: usize;
+ //~^ ERROR marker traits cannot have associated items
+}
+
+#[marker]
+trait MarkerType {
+ type Output;
+ //~^ ERROR marker traits cannot have associated items
+}
+
+#[marker]
+trait MarkerFn {
+ fn foo();
+ //~^ ERROR marker traits cannot have associated items
+}
+
+#[marker]
+trait MarkerConstWithDefault {
+ const N: usize = 43;
+ //~^ ERROR marker traits cannot have associated items
+}
+
+#[marker]
+trait MarkerTypeWithDefault {
+ type Output = ();
+ //~^ ERROR marker traits cannot have associated items
+}
+
+#[marker]
+trait MarkerFnWithDefault {
+ fn foo() {}
+ //~^ ERROR marker traits cannot have associated items
+}
+
+fn main() {}
diff --git a/tests/ui/marker_trait_attr/marker-trait-with-associated-items.stderr b/tests/ui/marker_trait_attr/marker-trait-with-associated-items.stderr
new file mode 100644
index 000000000..ac218e30b
--- /dev/null
+++ b/tests/ui/marker_trait_attr/marker-trait-with-associated-items.stderr
@@ -0,0 +1,39 @@
+error[E0714]: marker traits cannot have associated items
+ --> $DIR/marker-trait-with-associated-items.rs:6:5
+ |
+LL | const N: usize;
+ | ^^^^^^^^^^^^^^
+
+error[E0714]: marker traits cannot have associated items
+ --> $DIR/marker-trait-with-associated-items.rs:12:5
+ |
+LL | type Output;
+ | ^^^^^^^^^^^
+
+error[E0714]: marker traits cannot have associated items
+ --> $DIR/marker-trait-with-associated-items.rs:18:5
+ |
+LL | fn foo();
+ | ^^^^^^^^^
+
+error[E0714]: marker traits cannot have associated items
+ --> $DIR/marker-trait-with-associated-items.rs:24:5
+ |
+LL | const N: usize = 43;
+ | ^^^^^^^^^^^^^^
+
+error[E0714]: marker traits cannot have associated items
+ --> $DIR/marker-trait-with-associated-items.rs:30:5
+ |
+LL | type Output = ();
+ | ^^^^^^^^^^^
+
+error[E0714]: marker traits cannot have associated items
+ --> $DIR/marker-trait-with-associated-items.rs:36:5
+ |
+LL | fn foo() {}
+ | ^^^^^^^^
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0714`.
diff --git a/tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.rs b/tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.rs
new file mode 100644
index 000000000..1e413120a
--- /dev/null
+++ b/tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.rs
@@ -0,0 +1,20 @@
+// run-pass
+
+#![feature(marker_trait_attr)]
+#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
+
+#[marker]
+trait MyMarker {}
+
+impl<T> MyMarker for T {}
+impl<T> MyMarker for Vec<T> {}
+
+fn foo<T: MyMarker>(t: T) -> T {
+ t
+}
+
+fn main() {
+ assert_eq!(1, foo(1));
+ assert_eq!(2.0, foo(2.0));
+ assert_eq!(vec![1], foo(vec![1]));
+}
diff --git a/tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.stderr b/tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.stderr
new file mode 100644
index 000000000..649e58915
--- /dev/null
+++ b/tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.stderr
@@ -0,0 +1,12 @@
+warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/overlap-doesnt-conflict-with-specialization.rs:4:12
+ |
+LL | #![feature(specialization)]
+ | ^^^^^^^^^^^^^^
+ |
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
+ = help: consider using `min_specialization` instead, which is more stable and complete
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs
new file mode 100644
index 000000000..62aa22d41
--- /dev/null
+++ b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs
@@ -0,0 +1,10 @@
+// check-pass
+#![feature(marker_trait_attr)]
+
+#[marker]
+trait Marker {}
+
+impl Marker for &'static () {}
+impl Marker for &'static () {}
+
+fn main() {}
diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.rs b/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.rs
new file mode 100644
index 000000000..eabce1aef
--- /dev/null
+++ b/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.rs
@@ -0,0 +1,9 @@
+#![feature(marker_trait_attr)]
+
+#[marker]
+trait Marker {}
+
+impl Marker for &'_ () {} //~ ERROR type annotations needed
+impl Marker for &'_ () {} //~ ERROR type annotations needed
+
+fn main() {}
diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr b/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr
new file mode 100644
index 000000000..3cd59d692
--- /dev/null
+++ b/tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr
@@ -0,0 +1,31 @@
+error[E0283]: type annotations needed: cannot satisfy `&(): Marker`
+ --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:17
+ |
+LL | impl Marker for &'_ () {}
+ | ^^^^^^
+ |
+note: multiple `impl`s satisfying `&(): Marker` found
+ --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:1
+ |
+LL | impl Marker for &'_ () {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
+LL | impl Marker for &'_ () {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0283]: type annotations needed: cannot satisfy `&(): Marker`
+ --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:7:17
+ |
+LL | impl Marker for &'_ () {}
+ | ^^^^^^
+ |
+note: multiple `impl`s satisfying `&(): Marker` found
+ --> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:1
+ |
+LL | impl Marker for &'_ () {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
+LL | impl Marker for &'_ () {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait.rs b/tests/ui/marker_trait_attr/overlap-marker-trait.rs
new file mode 100644
index 000000000..67e551797
--- /dev/null
+++ b/tests/ui/marker_trait_attr/overlap-marker-trait.rs
@@ -0,0 +1,29 @@
+// Test for RFC 1268: we allow overlapping impls of marker traits,
+// that is, traits with #[marker]. In this case, a type `T` is
+// `MyMarker` if it is either `Debug` or `Display`. This test just
+// checks that we don't consider **all** types to be `MyMarker`.
+
+#![feature(marker_trait_attr)]
+
+use std::fmt::{Debug, Display};
+
+#[marker]
+trait Marker {}
+
+impl<T: Debug> Marker for T {}
+impl<T: Display> Marker for T {}
+
+fn is_marker<T: Marker>() { }
+
+struct NotDebugOrDisplay;
+
+fn main() {
+ // Debug && Display:
+ is_marker::<i32>();
+
+ // Debug && !Display:
+ is_marker::<Vec<i32>>();
+
+ // !Debug && !Display
+ is_marker::<NotDebugOrDisplay>(); //~ ERROR
+}
diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait.stderr b/tests/ui/marker_trait_attr/overlap-marker-trait.stderr
new file mode 100644
index 000000000..133bc0484
--- /dev/null
+++ b/tests/ui/marker_trait_attr/overlap-marker-trait.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `NotDebugOrDisplay: Marker` is not satisfied
+ --> $DIR/overlap-marker-trait.rs:28:17
+ |
+LL | is_marker::<NotDebugOrDisplay>();
+ | ^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay`
+ |
+note: required by a bound in `is_marker`
+ --> $DIR/overlap-marker-trait.rs:16:17
+ |
+LL | fn is_marker<T: Marker>() { }
+ | ^^^^^^ required by this bound in `is_marker`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/marker_trait_attr/overlap-permitted-for-annotated-marker-traits.rs b/tests/ui/marker_trait_attr/overlap-permitted-for-annotated-marker-traits.rs
new file mode 100644
index 000000000..f7654458f
--- /dev/null
+++ b/tests/ui/marker_trait_attr/overlap-permitted-for-annotated-marker-traits.rs
@@ -0,0 +1,27 @@
+// run-pass
+// Tests for RFC 1268: we allow overlapping impls of marker traits,
+// that is, traits with #[marker]. In this case, a type `T` is
+// `MyMarker` if it is either `Debug` or `Display`.
+
+#![feature(marker_trait_attr)]
+
+use std::fmt::{Debug, Display};
+
+#[marker]
+trait MyMarker {}
+
+impl<T: Debug> MyMarker for T {}
+impl<T: Display> MyMarker for T {}
+
+fn foo<T: MyMarker>(t: T) -> T {
+ t
+}
+
+fn main() {
+ // Debug && Display:
+ assert_eq!(1, foo(1));
+ assert_eq!(2.0, foo(2.0));
+
+ // Debug && !Display:
+ assert_eq!(vec![1], foo(vec![1]));
+}
diff --git a/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs
new file mode 100644
index 000000000..a8f3db5f5
--- /dev/null
+++ b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs
@@ -0,0 +1,9 @@
+// check-pass
+#![feature(marker_trait_attr)]
+
+#[marker]
+pub trait F {}
+impl<T> F for T where T: Copy {}
+impl<T> F for T where T: 'static {}
+
+fn main() {}
diff --git a/tests/ui/marker_trait_attr/override-item-on-marker-trait.rs b/tests/ui/marker_trait_attr/override-item-on-marker-trait.rs
new file mode 100644
index 000000000..5376fc89d
--- /dev/null
+++ b/tests/ui/marker_trait_attr/override-item-on-marker-trait.rs
@@ -0,0 +1,23 @@
+#![feature(marker_trait_attr)]
+
+#[marker]
+trait Marker {
+ const N: usize = 0;
+ fn do_something() {}
+}
+
+struct OverrideConst;
+impl Marker for OverrideConst {
+//~^ ERROR impls for marker traits cannot contain items
+ const N: usize = 1;
+}
+
+struct OverrideFn;
+impl Marker for OverrideFn {
+//~^ ERROR impls for marker traits cannot contain items
+ fn do_something() {
+ println!("Hello world!");
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/marker_trait_attr/override-item-on-marker-trait.stderr b/tests/ui/marker_trait_attr/override-item-on-marker-trait.stderr
new file mode 100644
index 000000000..1d30c6d56
--- /dev/null
+++ b/tests/ui/marker_trait_attr/override-item-on-marker-trait.stderr
@@ -0,0 +1,15 @@
+error[E0715]: impls for marker traits cannot contain items
+ --> $DIR/override-item-on-marker-trait.rs:10:1
+ |
+LL | impl Marker for OverrideConst {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0715]: impls for marker traits cannot contain items
+ --> $DIR/override-item-on-marker-trait.rs:16:1
+ |
+LL | impl Marker for OverrideFn {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0715`.
diff --git a/tests/ui/marker_trait_attr/region-overlap.rs b/tests/ui/marker_trait_attr/region-overlap.rs
new file mode 100644
index 000000000..b3c667103
--- /dev/null
+++ b/tests/ui/marker_trait_attr/region-overlap.rs
@@ -0,0 +1,8 @@
+#![feature(marker_trait_attr)]
+
+#[marker]
+trait A {}
+impl<'a> A for (&'static (), &'a ()) {} //~ ERROR type annotations needed
+impl<'a> A for (&'a (), &'static ()) {} //~ ERROR type annotations needed
+
+fn main() {}
diff --git a/tests/ui/marker_trait_attr/region-overlap.stderr b/tests/ui/marker_trait_attr/region-overlap.stderr
new file mode 100644
index 000000000..c6497b466
--- /dev/null
+++ b/tests/ui/marker_trait_attr/region-overlap.stderr
@@ -0,0 +1,31 @@
+error[E0283]: type annotations needed: cannot satisfy `(&'static (), &'a ()): A`
+ --> $DIR/region-overlap.rs:5:16
+ |
+LL | impl<'a> A for (&'static (), &'a ()) {}
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+note: multiple `impl`s satisfying `(&'static (), &'a ()): A` found
+ --> $DIR/region-overlap.rs:5:1
+ |
+LL | impl<'a> A for (&'static (), &'a ()) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<'a> A for (&'a (), &'static ()) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0283]: type annotations needed: cannot satisfy `(&'a (), &'static ()): A`
+ --> $DIR/region-overlap.rs:6:16
+ |
+LL | impl<'a> A for (&'a (), &'static ()) {}
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+note: multiple `impl`s satisfying `(&'a (), &'static ()): A` found
+ --> $DIR/region-overlap.rs:5:1
+ |
+LL | impl<'a> A for (&'static (), &'a ()) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<'a> A for (&'a (), &'static ()) {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0283`.
diff --git a/tests/ui/marker_trait_attr/unsound-overlap.rs b/tests/ui/marker_trait_attr/unsound-overlap.rs
new file mode 100644
index 000000000..2e5101b82
--- /dev/null
+++ b/tests/ui/marker_trait_attr/unsound-overlap.rs
@@ -0,0 +1,25 @@
+#![feature(marker_trait_attr)]
+
+#[marker]
+trait A {}
+
+trait B {}
+
+impl<T: A> B for T {}
+impl<T: B> A for T {}
+impl A for &str {}
+impl<T: A + B> A for (T,) {}
+trait TraitWithAssoc {
+ type Assoc;
+}
+
+impl<T: A> TraitWithAssoc for T {
+ type Assoc = T;
+}
+
+impl TraitWithAssoc for ((&str,),) {
+ //~^ ERROR conflicting implementations
+ type Assoc = ((&'static str,),);
+}
+
+fn main() {}
diff --git a/tests/ui/marker_trait_attr/unsound-overlap.stderr b/tests/ui/marker_trait_attr/unsound-overlap.stderr
new file mode 100644
index 000000000..5ebac8270
--- /dev/null
+++ b/tests/ui/marker_trait_attr/unsound-overlap.stderr
@@ -0,0 +1,12 @@
+error[E0119]: conflicting implementations of trait `TraitWithAssoc` for type `((&str,),)`
+ --> $DIR/unsound-overlap.rs:20:1
+ |
+LL | impl<T: A> TraitWithAssoc for T {
+ | ------------------------------- first implementation here
+...
+LL | impl TraitWithAssoc for ((&str,),) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `((&str,),)`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0119`.