Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rustc_strict_coherence attribute and use it to check overlap
- Loading branch information
1 parent
74454c4
commit da79fa9
Showing
6 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/test/ui/coherence/coherence-overlap-negate-alias-strict.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/coherence/coherence-overlap-negate-alias-strict.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |