-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test demonstrating that RPITITs cant use precise capturing
- Loading branch information
1 parent
1aaab8b
commit dd557d8
Showing
2 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@ known-bug: unknown | ||
|
||
// RPITITs don't have variances in their GATs, so they always relate invariantly | ||
// and act as if they capture all their args. | ||
// To fix this soundly, we need to make sure that all the trait header args | ||
// remain captured, since they affect trait selection. | ||
|
||
#![feature(precise_capturing)] | ||
|
||
trait Foo<'a> { | ||
fn hello() -> impl PartialEq + use<Self>; | ||
} | ||
|
||
fn test<'a, 'b, T: for<'r> Foo<'r>>() { | ||
PartialEq::eq( | ||
&<T as Foo<'a>>::hello(), | ||
&<T as Foo<'b>>::hello(), | ||
); | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
error: `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list | ||
--> $DIR/rpitit.rs:11:19 | ||
| | ||
LL | trait Foo<'a> { | ||
| -- this lifetime parameter is captured | ||
LL | fn hello() -> impl PartialEq + use<Self>; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime captured due to being mentioned in the bounds of the `impl Trait` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/rpitit.rs:15:5 | ||
| | ||
LL | fn test<'a, 'b, T: for<'r> Foo<'r>>() { | ||
| -- -- lifetime `'b` defined here | ||
| | | ||
| lifetime `'a` defined here | ||
LL | / PartialEq::eq( | ||
LL | | &<T as Foo<'a>>::hello(), | ||
LL | | &<T as Foo<'b>>::hello(), | ||
LL | | ); | ||
| |_____^ argument requires that `'a` must outlive `'b` | ||
| | ||
= help: consider adding the following bound: `'a: 'b` | ||
|
||
error: lifetime may not live long enough | ||
--> $DIR/rpitit.rs:15:5 | ||
| | ||
LL | fn test<'a, 'b, T: for<'r> Foo<'r>>() { | ||
| -- -- lifetime `'b` defined here | ||
| | | ||
| lifetime `'a` defined here | ||
LL | / PartialEq::eq( | ||
LL | | &<T as Foo<'a>>::hello(), | ||
LL | | &<T as Foo<'b>>::hello(), | ||
LL | | ); | ||
| |_____^ argument requires that `'b` must outlive `'a` | ||
| | ||
= help: consider adding the following bound: `'b: 'a` | ||
|
||
help: `'a` and `'b` must be the same: replace one with the other | ||
|
||
error: aborting due to 3 previous errors | ||
|