-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
218 additions
and
159 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,9 @@ | ||
// Test that our leak-check is not smart enough to take implied bounds | ||
// into account (yet). Here we have two types that look like they | ||
// should not be equivalent, but because of the rules on implied | ||
// bounds we ought to know that, in fact, `'a = 'b` must always hold, | ||
// and hence they are. | ||
// | ||
// Rustc can't figure this out and hence it accepts the impls but | ||
// gives a future-compatibility warning (because we'd like to make | ||
// this an error someday). | ||
// | ||
// Note that while we would like to make this a hard error, we also | ||
// give the same warning for `coherence-wasm-bindgen.rs`, which ought | ||
// to be accepted. | ||
|
||
#![deny(coherence_leak_check)] | ||
|
||
trait Trait {} | ||
|
||
impl Trait for for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32 {} | ||
|
||
impl Trait for for<'c> fn(&'c &'c u32, &'c &'c u32) -> &'c u32 { | ||
//~^ ERROR conflicting implementations | ||
//~| WARNING this was previously accepted by the compiler | ||
} | ||
|
||
fn main() {} |
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 |
---|---|---|
@@ -1,20 +1,14 @@ | ||
error: conflicting implementations of trait `Trait` for type `for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32` | ||
--> $DIR/coherence-fn-implied-bounds.rs:21:1 | ||
error[E0119]: conflicting implementations of trait `Trait` for type `for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32` | ||
--> $DIR/coherence-fn-implied-bounds.rs:5:1 | ||
| | ||
LL | impl Trait for for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32 {} | ||
| ------------------------------------------------------------------ first implementation here | ||
LL | | ||
LL | impl Trait for for<'c> fn(&'c &'c u32, &'c &'c u32) -> &'c u32 { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a &'b u32, &'b &'a u32) -> &'b u32` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105> | ||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details | ||
note: the lint level is defined here | ||
--> $DIR/coherence-fn-implied-bounds.rs:15:9 | ||
| | ||
LL | #![deny(coherence_leak_check)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
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
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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
warning: conflicting implementations of trait `TheTrait` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` | ||
--> $DIR/coherence-subtyping.rs:15:1 | ||
error[E0119]: conflicting implementations of trait `TheTrait` for type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` | ||
--> $DIR/coherence-subtyping.rs:10:1 | ||
| | ||
LL | impl TheTrait for for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8 {} | ||
| ---------------------------------------------------------- first implementation here | ||
LL | | ||
LL | impl TheTrait for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105> | ||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details | ||
= note: `#[warn(coherence_leak_check)]` on by default | ||
|
||
warning: 1 warning emitted | ||
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,81 @@ | ||
// compile-flags: -Ztrait-solver=next | ||
trait Relate {} | ||
|
||
struct Outlives<'a, 'b>(&'a u8, &'b u8); | ||
impl<'a, 'b> Relate for Outlives<'a, 'b> where 'a: 'b, {} | ||
|
||
struct Equal<'a, 'b>(&'a u8, &'b u8); | ||
impl<'a> Relate for Equal<'a, 'a> {} | ||
|
||
macro_rules! rule { | ||
( $name:ident<$($lt:lifetime),*> :- $( ($($bound:tt)*) ),* ) => { | ||
struct $name<$($lt),*>($(&$lt u8),*); | ||
impl<$($lt),*> $crate::Relate for $name<$($lt),*> | ||
where $( $($bound)*: $crate::Relate, )* | ||
{} | ||
}; | ||
} | ||
|
||
// ---- | ||
|
||
trait CoherenceTrait {} | ||
impl<T> CoherenceTrait for T {} | ||
|
||
macro_rules! assert_false_by_leak_check { | ||
( exist<$($lt:lifetime),*> $( ($($bound:tt)*) ),* ) => { | ||
struct Unique<$($lt),*>($(&$lt u8),*); | ||
impl<$($lt),*> $crate::CoherenceTrait for Unique<$($lt),*> | ||
//~^ ERROR for type `test1::Unique` | ||
//~| ERROR for type `test3::Unique` | ||
//~| ERROR for type `test6::Unique` | ||
where $( $($bound)*: $crate::Relate, )* | ||
{} | ||
}; | ||
} | ||
|
||
mod test1 { | ||
use super::*; | ||
assert_false_by_leak_check!( | ||
exist<> (for<'a, 'b> Outlives<'a, 'b>) | ||
); | ||
} | ||
|
||
mod test2 { | ||
use super::*; | ||
assert_false_by_leak_check!( | ||
exist<'a> (for<'b> Outlives<'b, 'a>) | ||
); | ||
} | ||
|
||
mod test3 { | ||
use super::*; | ||
rule!( OutlivesPlaceholder<'a> :- (for<'b> Outlives<'a, 'b>) ); | ||
assert_false_by_leak_check!( | ||
exist<> (for<'a> OutlivesPlaceholder<'a>) | ||
); | ||
} | ||
|
||
mod test4 { | ||
use super::*; | ||
rule!( OutlivedByPlaceholder<'a> :- (for<'b> Outlives<'b, 'a>) ); | ||
assert_false_by_leak_check!( | ||
exist<> (for<'a> OutlivedByPlaceholder<'a>) | ||
); | ||
} | ||
|
||
mod test5 { | ||
use super::*; | ||
rule!( EqualsPlaceholder<'a> :- (for<'b> Equal<'b, 'a>) ); | ||
assert_false_by_leak_check!( | ||
exist<> (for<'a> EqualsPlaceholder<'a>) | ||
); | ||
} | ||
|
||
mod test6 { | ||
use super::*; | ||
assert_false_by_leak_check!( | ||
exist<> (for<'a, 'b> Equal<'a, 'b>) | ||
); | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.