-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Use fulfillment to check Drop
impl compatibility
#110577
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
Merged
+448
−234
Merged
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,35 @@ | ||
error[E0277]: the trait bound `T: Copy` is not satisfied | ||
--> $DIR/explicit-drop-bounds.rs:27:18 | ||
| | ||
LL | impl<T> Drop for DropMe<T> | ||
| ^^^^^^^^^ the trait `Copy` is not implemented for `T` | ||
| | ||
note: required by a bound in `DropMe` | ||
--> $DIR/explicit-drop-bounds.rs:7:18 | ||
| | ||
LL | struct DropMe<T: Copy>(T); | ||
| ^^^^ required by this bound in `DropMe` | ||
help: consider further restricting type parameter `T` | ||
| | ||
LL | [T; 1]: Copy, T: std::marker::Copy // But `[T; 1]: Copy` does not imply `T: Copy` | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error[E0277]: the trait bound `T: Copy` is not satisfied | ||
--> $DIR/explicit-drop-bounds.rs:32:13 | ||
| | ||
LL | fn drop(&mut self) {} | ||
| ^^^^^^^^^ the trait `Copy` is not implemented for `T` | ||
| | ||
note: required by a bound in `DropMe` | ||
--> $DIR/explicit-drop-bounds.rs:7:18 | ||
| | ||
LL | struct DropMe<T: Copy>(T); | ||
| ^^^^ required by this bound in `DropMe` | ||
help: consider further restricting type parameter `T` | ||
| | ||
LL | [T; 1]: Copy, T: std::marker::Copy // But `[T; 1]: Copy` does not imply `T: Copy` | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains hidden or 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,35 @@ | ||
error[E0277]: the trait bound `T: Copy` is not satisfied | ||
--> $DIR/explicit-drop-bounds.rs:37:18 | ||
| | ||
LL | impl<T> Drop for DropMe<T> | ||
| ^^^^^^^^^ the trait `Copy` is not implemented for `T` | ||
| | ||
note: required by a bound in `DropMe` | ||
--> $DIR/explicit-drop-bounds.rs:7:18 | ||
| | ||
LL | struct DropMe<T: Copy>(T); | ||
| ^^^^ required by this bound in `DropMe` | ||
help: consider restricting type parameter `T` | ||
| | ||
LL | impl<T: std::marker::Copy> Drop for DropMe<T> | ||
| +++++++++++++++++++ | ||
|
||
error[E0277]: the trait bound `T: Copy` is not satisfied | ||
--> $DIR/explicit-drop-bounds.rs:40:13 | ||
| | ||
LL | fn drop(&mut self) {} | ||
| ^^^^^^^^^ the trait `Copy` is not implemented for `T` | ||
| | ||
note: required by a bound in `DropMe` | ||
--> $DIR/explicit-drop-bounds.rs:7:18 | ||
| | ||
LL | struct DropMe<T: Copy>(T); | ||
| ^^^^ required by this bound in `DropMe` | ||
help: consider restricting type parameter `T` | ||
| | ||
LL | impl<T: std::marker::Copy> Drop for DropMe<T> | ||
| +++++++++++++++++++ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
This file contains hidden or 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,44 @@ | ||
// revisions: good1 good2 bad1 bad2 | ||
//[good1] check-pass | ||
//[good2] check-pass | ||
|
||
use std::ops::Drop; | ||
|
||
struct DropMe<T: Copy>(T); | ||
|
||
#[cfg(good1)] | ||
impl<T> Drop for DropMe<T> | ||
where | ||
T: Copy + Clone, | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
#[cfg(good2)] | ||
impl<T> Drop for DropMe<T> | ||
where | ||
T: Copy, | ||
[T; 1]: Copy, // Trivial bound implied by `T: Copy` | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
#[cfg(bad1)] | ||
impl<T> Drop for DropMe<T> | ||
//[bad1]~^ ERROR the trait bound `T: Copy` is not satisfied | ||
where | ||
[T; 1]: Copy, // But `[T; 1]: Copy` does not imply `T: Copy` | ||
{ | ||
fn drop(&mut self) {} | ||
//[bad1]~^ ERROR the trait bound `T: Copy` is not satisfied | ||
} | ||
|
||
#[cfg(bad2)] | ||
impl<T> Drop for DropMe<T> | ||
//[bad2]~^ ERROR the trait bound `T: Copy` is not satisfied | ||
{ | ||
fn drop(&mut self) {} | ||
//[bad2]~^ ERROR the trait bound `T: Copy` is not satisfied | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,15 @@ | ||
error[E0367]: `Drop` impl requires `T: 'static` but the struct it is implemented for does not | ||
--> $DIR/explicit-implied-outlives.rs:28:8 | ||
| | ||
LL | T: 'static, | ||
| ^^^^^^^ | ||
| | ||
note: the implementor must specify the same requirement | ||
--> $DIR/explicit-implied-outlives.rs:7:1 | ||
| | ||
LL | struct DropMe<'a, T>(&'a T); | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0367`. |
This file contains hidden or 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,15 @@ | ||
error[E0367]: `Drop` impl requires `'a: 'static` but the struct it is implemented for does not | ||
--> $DIR/explicit-implied-outlives.rs:37:9 | ||
| | ||
LL | 'a: 'static, | ||
| ^^^^^^^ | ||
| | ||
note: the implementor must specify the same requirement | ||
--> $DIR/explicit-implied-outlives.rs:7:1 | ||
| | ||
LL | struct DropMe<'a, T>(&'a T); | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0367`. |
This file contains hidden or 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,43 @@ | ||
// revisions: good1 good2 bad1 bad2 | ||
//[good1] check-pass | ||
//[good2] check-pass | ||
|
||
use std::ops::Drop; | ||
|
||
struct DropMe<'a, T>(&'a T); | ||
|
||
#[cfg(good1)] | ||
impl<'a, T> Drop for DropMe<'a, T> | ||
where | ||
T: 'a, // Implied by struct, explicit on impl | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
#[cfg(good2)] | ||
impl<'a, T> Drop for DropMe<'a, T> | ||
where | ||
'static: 'a, // Trivial bound | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
#[cfg(bad1)] | ||
impl<'a, T> Drop for DropMe<'a, T> | ||
where | ||
T: 'static, | ||
//[bad1]~^ ERROR `Drop` impl requires `T: 'static` | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
#[cfg(bad2)] | ||
impl<'a, T> Drop for DropMe<'a, T> | ||
where | ||
'a: 'static, | ||
//[bad2]~^ ERROR `Drop` impl requires `'a: 'static` | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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 | ||
|
||
use std::marker::PhantomData; | ||
use std::ops::Drop; | ||
|
||
// a >= b >= c >= a implies a = b = c | ||
struct DropMe<'a: 'b, 'b: 'c, 'c: 'a>( | ||
PhantomData<&'a ()>, | ||
PhantomData<&'b ()>, | ||
PhantomData<&'c ()>, | ||
); | ||
|
||
// a >= b, a >= c, b >= a, c >= a implies a = b = c | ||
impl<'a: 'b + 'c, 'b: 'a, 'c: 'a> Drop for DropMe<'a, 'b, 'c> { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,15 @@ | ||
error[E0367]: `Drop` impl requires `'a: 'c` but the struct it is implemented for does not | ||
--> $DIR/transitive-outlives.rs:20:9 | ||
| | ||
LL | 'a: 'c, | ||
| ^^ | ||
| | ||
note: the implementor must specify the same requirement | ||
--> $DIR/transitive-outlives.rs:7:1 | ||
| | ||
LL | struct DropMe<'a, 'b: 'a, 'c: 'b>(PhantomData<&'a ()>, PhantomData<&'b ()>, PhantomData<&'c ()>); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0367`. |
This file contains hidden or 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,26 @@ | ||
// revisions: good bad | ||
//[good] check-pass | ||
|
||
use std::marker::PhantomData; | ||
use std::ops::Drop; | ||
|
||
struct DropMe<'a, 'b: 'a, 'c: 'b>(PhantomData<&'a ()>, PhantomData<&'b ()>, PhantomData<&'c ()>); | ||
|
||
#[cfg(good)] | ||
impl<'a, 'b, 'c> Drop for DropMe<'a, 'b, 'c> | ||
where | ||
'c: 'a, | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
#[cfg(bad)] | ||
impl<'a, 'b, 'c> Drop for DropMe<'a, 'b, 'c> | ||
where | ||
'a: 'c, | ||
//[bad]~^ ERROR `Drop` impl requires `'a: 'c` | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
fn main() {} |
This file contains hidden or 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,34 @@ | ||
// revisions: good1 good2 good3 | ||
// check-pass | ||
|
||
use std::ops::Drop; | ||
|
||
struct Foo; | ||
|
||
const X: usize = 1; | ||
|
||
#[cfg(good1)] | ||
impl Drop for Foo | ||
where | ||
[(); X]:, // Trivial WF bound | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
#[cfg(good2)] | ||
impl Drop for Foo | ||
where | ||
for<'a> &'a (): Copy, // Trivial trait bound | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
#[cfg(good3)] | ||
impl Drop for Foo | ||
where | ||
for<'a> &'a (): 'a, // Trivial outlives bound | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
fn main() {} |
24 changes: 24 additions & 0 deletions
24
tests/ui/traits/non_lifetime_binders/drop-impl-pred.no.stderr
This file contains hidden or 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,24 @@ | ||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/drop-impl-pred.rs:6:12 | ||
| | ||
LL | #![feature(non_lifetime_binders)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0367]: `Drop` impl requires `H: Foo` but the struct it is implemented for does not | ||
--> $DIR/drop-impl-pred.rs:19:15 | ||
| | ||
LL | for<H> H: Foo, | ||
| ^^^ | ||
| | ||
note: the implementor must specify the same requirement | ||
--> $DIR/drop-impl-pred.rs:12:1 | ||
| | ||
LL | struct Bar<T>(T) where T: Foo; | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0367`. |
This file contains hidden or 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,25 @@ | ||
// revisions: no yes | ||
//[yes] check-pass | ||
|
||
// Issue 110557 | ||
|
||
#![feature(non_lifetime_binders)] | ||
//~^ WARN the feature `non_lifetime_binders` is incomplete | ||
|
||
pub trait Foo {} | ||
|
||
#[cfg(no)] | ||
struct Bar<T>(T) where T: Foo; | ||
|
||
#[cfg(yes)] | ||
struct Bar<T>(T) where for<H> H: Foo; | ||
|
||
impl<T> Drop for Bar<T> | ||
where | ||
for<H> H: Foo, | ||
//[no]~^ ERROR `Drop` impl requires `H: Foo` but the struct it is implemented for does not | ||
{ | ||
fn drop(&mut self) {} | ||
} | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui/traits/non_lifetime_binders/drop-impl-pred.yes.stderr
This file contains hidden or 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,11 @@ | ||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/drop-impl-pred.rs:6:12 | ||
| | ||
LL | #![feature(non_lifetime_binders)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.