-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #135000 - compiler-errors:opaque-captures-dupe, r=lqd
Fix ICE when opaque captures a duplicated/invalid lifetime See description on test. Fixes #132766 Fixes #133693 Fixes #134780
- Loading branch information
Showing
8 changed files
with
53 additions
and
27 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 was deleted.
Oops, something went wrong.
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 @@ | ||
// This uses edition 2024 for new lifetime capture rules. | ||
//@ edition: 2024 | ||
|
||
// The problem here is that the presence of the opaque which captures all lifetimes in scope | ||
// means that the duplicated `'a` (which I'll call the dupe) is considered to be *early-bound* | ||
// since it shows up in the output but not the inputs. This is paired with the fact that we | ||
// were previously setting the name of the dupe to `'_` in the generic param definition, which | ||
// means that the identity args for the function were `['a#0, '_#1]` even though the lifetime | ||
// for the dupe should've been `'a#1`. This difference in symbol meant that NLL couldn't | ||
// actually match the lifetime against the identity lifetimes, leading to an ICE. | ||
|
||
struct Foo<'a>(&'a ()); | ||
|
||
impl<'a> Foo<'a> { | ||
fn pass<'a>() -> impl Sized {} | ||
//~^ ERROR lifetime name `'a` shadows a lifetime name that is already in scope | ||
} | ||
|
||
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,11 @@ | ||
error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope | ||
--> $DIR/captured-invalid-lifetime.rs:15:13 | ||
| | ||
LL | impl<'a> Foo<'a> { | ||
| -- first declared here | ||
LL | fn pass<'a>() -> impl Sized {} | ||
| ^^ lifetime `'a` already in scope | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0496`. |
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