Closed
Description
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=aaf294b9353da9ea4ef76206ed0c0a76
fn test<'a, T>() {
|| {
None::<&'a T>;
};
}
The current output is:
error[E0309]: the parameter type `T` may not live long enough
--> src/lib.rs:2:5
|
2 | / || {
3 | | None::<&'a T>;
4 | | };
| |_____^ ...so that the type `T` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound...
|
1 | fn test<'a, T: 'a>() {
| ++++
Ideally the output should look similar to when constraint is generated in the main fn body:
error[E0309]: the parameter type `T` may not live long enough
--> src/lib.rs:3:9
|
3 | None::<&'a T>;
| ^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound...
|
1 | fn test<'a, T: 'a>() {
| ++++
@rustbot label A-NLL NLL-diagnostics D-terse regression-from-stable-to-beta
Metadata
Metadata
Assignees
Labels
Area: Non-lexical lifetimes (NLL)Area: Messages for errors, warnings, and lintsDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Working towards the "diagnostic parity" goalMedium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.