-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
promote placeholder bounds to 'static obligations
In NLL, when we are promoting a bound out from a closure, if we have a requirement that `T: 'a` where `'a` is in a higher universe, we were previously ignoring that, which is totally wrong. We should be promoting those constraints to `'static`, since universes are not expressible across closure boundaries.
- Loading branch information
1 parent
7425fb2
commit 7fda862
Showing
5 changed files
with
85 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Regression test for #98693. | ||
// | ||
// The closure encounters an obligation that `T` must outlive `!U1`, | ||
// a placeholder from universe U1. We were ignoring this placeholder | ||
// when promoting the constraint to the enclosing function, and | ||
// thus incorrectly judging the closure to be safe. | ||
|
||
fn assert_static<T>() | ||
where | ||
for<'a> T: 'a, | ||
{ | ||
} | ||
|
||
fn test<T>() { | ||
|| { | ||
//~^ ERROR the parameter type `T` may not live long enough | ||
assert_static::<T>(); | ||
}; | ||
} | ||
|
||
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,17 @@ | ||
error[E0310]: the parameter type `T` may not live long enough | ||
--> $DIR/issue-98693.rs:15:5 | ||
| | ||
LL | / || { | ||
LL | | | ||
LL | | assert_static::<T>(); | ||
LL | | }; | ||
| |_____^ ...so that the type `T` will meet its required lifetime bounds | ||
| | ||
help: consider adding an explicit lifetime bound... | ||
| | ||
LL | fn test<T: 'static>() { | ||
| +++++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0310`. |