From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../marker_trait_attr/issue-61651-type-mismatch.rs | 17 +++++++ .../marker-attribute-on-non-trait.rs | 23 ++++++++++ .../marker-attribute-on-non-trait.stderr | 52 ++++++++++++++++++++++ .../marker-attribute-with-values.rs | 12 +++++ .../marker-attribute-with-values.stderr | 20 +++++++++ .../marker-trait-with-associated-items.rs | 40 +++++++++++++++++ .../marker-trait-with-associated-items.stderr | 39 ++++++++++++++++ .../overlap-doesnt-conflict-with-specialization.rs | 20 +++++++++ ...rlap-doesnt-conflict-with-specialization.stderr | 12 +++++ .../overlap-marker-trait-with-static-lifetime.rs | 10 +++++ ...verlap-marker-trait-with-underscore-lifetime.rs | 9 ++++ ...ap-marker-trait-with-underscore-lifetime.stderr | 31 +++++++++++++ tests/ui/marker_trait_attr/overlap-marker-trait.rs | 29 ++++++++++++ .../marker_trait_attr/overlap-marker-trait.stderr | 15 +++++++ ...verlap-permitted-for-annotated-marker-traits.rs | 27 +++++++++++ .../overlapping-impl-1-modulo-regions.rs | 9 ++++ .../override-item-on-marker-trait.rs | 23 ++++++++++ .../override-item-on-marker-trait.stderr | 15 +++++++ tests/ui/marker_trait_attr/region-overlap.rs | 8 ++++ tests/ui/marker_trait_attr/region-overlap.stderr | 31 +++++++++++++ tests/ui/marker_trait_attr/unsound-overlap.rs | 25 +++++++++++ tests/ui/marker_trait_attr/unsound-overlap.stderr | 12 +++++ 22 files changed, 479 insertions(+) create mode 100644 tests/ui/marker_trait_attr/issue-61651-type-mismatch.rs create mode 100644 tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs create mode 100644 tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr create mode 100644 tests/ui/marker_trait_attr/marker-attribute-with-values.rs create mode 100644 tests/ui/marker_trait_attr/marker-attribute-with-values.stderr create mode 100644 tests/ui/marker_trait_attr/marker-trait-with-associated-items.rs create mode 100644 tests/ui/marker_trait_attr/marker-trait-with-associated-items.stderr create mode 100644 tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.rs create mode 100644 tests/ui/marker_trait_attr/overlap-doesnt-conflict-with-specialization.stderr create mode 100644 tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs create mode 100644 tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.rs create mode 100644 tests/ui/marker_trait_attr/overlap-marker-trait-with-underscore-lifetime.stderr create mode 100644 tests/ui/marker_trait_attr/overlap-marker-trait.rs create mode 100644 tests/ui/marker_trait_attr/overlap-marker-trait.stderr create mode 100644 tests/ui/marker_trait_attr/overlap-permitted-for-annotated-marker-traits.rs create mode 100644 tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs create mode 100644 tests/ui/marker_trait_attr/override-item-on-marker-trait.rs create mode 100644 tests/ui/marker_trait_attr/override-item-on-marker-trait.stderr create mode 100644 tests/ui/marker_trait_attr/region-overlap.rs create mode 100644 tests/ui/marker_trait_attr/region-overlap.stderr create mode 100644 tests/ui/marker_trait_attr/unsound-overlap.rs create mode 100644 tests/ui/marker_trait_attr/unsound-overlap.stderr (limited to 'tests/ui/marker_trait_attr') 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 {} +impl Foo for u8 {} +impl Foo<[u8; 1]> for u8 {} +fn foo, 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 MyMarker for T {} +impl MyMarker for Vec {} + +fn foo(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 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 Marker for T {} +impl Marker for T {} + +fn is_marker() { } + +struct NotDebugOrDisplay; + +fn main() { + // Debug && Display: + is_marker::(); + + // Debug && !Display: + is_marker::>(); + + // !Debug && !Display + is_marker::(); //~ 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::(); + | ^^^^^^^^^^^^^^^^^ 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() { } + | ^^^^^^ 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 MyMarker for T {} +impl MyMarker for T {} + +fn foo(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 F for T where T: Copy {} +impl 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 B for T {} +impl A for T {} +impl A for &str {} +impl A for (T,) {} +trait TraitWithAssoc { + type Assoc; +} + +impl 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 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`. -- cgit v1.2.3