-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
relax leak-check #112999
Closed
Closed
relax leak-check #112999
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so it "relaxes" the coherence leak check by making the check more accurate w.r.t. implied bounds?