forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#105102 - compiler-errors:copy-impl-considerin…
…g-regions, r=lcnr Check ADT fields for copy implementations considering regions Fixes rust-lang#88901 r? `@ghost`
- Loading branch information
Showing
10 changed files
with
218 additions
and
102 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
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
22 changes: 22 additions & 0 deletions
22
tests/ui/traits/copy-is-not-modulo-regions.not_static.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,22 @@ | ||
error[E0204]: the trait `Copy` may not be implemented for this type | ||
--> $DIR/copy-is-not-modulo-regions.rs:13:21 | ||
| | ||
LL | struct Bar<'lt>(Foo<'lt>); | ||
| -------- this field does not implement `Copy` | ||
... | ||
LL | impl<'any> Copy for Bar<'any> {} | ||
| ^^^^^^^^^ | ||
| | ||
note: the `Copy` impl for `Foo<'any>` requires that `'any: 'static` | ||
--> $DIR/copy-is-not-modulo-regions.rs:10:17 | ||
| | ||
LL | struct Bar<'lt>(Foo<'lt>); | ||
| ^^^^^^^^ | ||
help: consider restricting type parameter `'any` | ||
| | ||
LL | impl<'any: 'static> Copy for Bar<'any> {} | ||
| +++++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0204`. |
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 @@ | ||
// revisions: not_static yes_static | ||
//[yes_static] check-pass | ||
|
||
#[derive(Clone)] | ||
struct Foo<'lt>(&'lt ()); | ||
|
||
impl Copy for Foo<'static> {} | ||
|
||
#[derive(Clone)] | ||
struct Bar<'lt>(Foo<'lt>); | ||
|
||
#[cfg(not_static)] | ||
impl<'any> Copy for Bar<'any> {} | ||
//[not_static]~^ the trait `Copy` may not be implemented for this type | ||
|
||
#[cfg(yes_static)] | ||
impl<'any> Copy for Bar<'static> {} | ||
|
||
fn main() {} |
Oops, something went wrong.