diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2021-10-22 15:44:28 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2021-10-22 15:49:46 -0300 |
| commit | da79fa964cfe82cfca3d9db6e32108888c837459 (patch) | |
| tree | 25f617a7d92bc672a0b13681b3d89656292d0e78 /src/test/ui | |
| parent | 74454c4888a0a5a5bca17b5adb1440c6b552608b (diff) | |
| download | rust-da79fa964cfe82cfca3d9db6e32108888c837459.tar.gz rust-da79fa964cfe82cfca3d9db6e32108888c837459.zip | |
Add rustc_strict_coherence attribute and use it to check overlap
Diffstat (limited to 'src/test/ui')
3 files changed, 49 insertions, 0 deletions
diff --git a/src/test/ui/coherence/coherence-overlap-negate-alias-strict.rs b/src/test/ui/coherence/coherence-overlap-negate-alias-strict.rs new file mode 100644 index 00000000000..16ace450b06 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-negate-alias-strict.rs @@ -0,0 +1,19 @@ +#![feature(negative_impls)] +#![feature(rustc_attrs)] +#![feature(trait_alias)] + +trait A {} +trait B {} +trait AB = A + B; + +impl !A for u32 {} + +trait C {} +#[rustc_strict_coherence] +impl<T: AB> C for T {} +#[rustc_strict_coherence] +impl C for u32 {} +//~^ ERROR: conflicting implementations of trait `C` for type `u32` [E0119] +// FIXME this should work, we should implement an `assemble_neg_candidates` fn + +fn main() {} diff --git a/src/test/ui/coherence/coherence-overlap-negate-alias-strict.stderr b/src/test/ui/coherence/coherence-overlap-negate-alias-strict.stderr new file mode 100644 index 00000000000..5e436223119 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-negate-alias-strict.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `C` for type `u32` + --> $DIR/coherence-overlap-negate-alias-strict.rs:15:1 + | +LL | impl<T: AB> C for T {} + | ------------------- first implementation here +LL | #[rustc_strict_coherence] +LL | impl C for u32 {} + | ^^^^^^^^^^^^^^ conflicting implementation for `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-negate-strict.rs b/src/test/ui/coherence/coherence-overlap-negate-strict.rs new file mode 100644 index 00000000000..b3ae9a7bf78 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-negate-strict.rs @@ -0,0 +1,18 @@ +// check-pass + +#![feature(negative_impls)] +#![feature(rustc_attrs)] +#![feature(trait_alias)] + +trait A {} +trait B {} + +impl !A for u32 {} + +trait C {} +#[rustc_strict_coherence] +impl<T: A + B> C for T {} +#[rustc_strict_coherence] +impl C for u32 {} + +fn main() {} |
