-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
fn foo<T>(_: T)
where
for<'a> T: 'a,
{}
fn main() {
let local = 1;
foo(&local);
}
results in
error[E0597]: `local` does not live long enough
--> src/main.rs:8:9
|
7 | let local = 1;
| ----- binding `local` declared here
8 | foo(&local);
| ----^^^^^^-
| | |
| | borrowed value does not live long enough
| argument requires that `local` is borrowed for `'static`
9 | }
| - `local` dropped here while still borrowed
|
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
--> src/main.rs:3:16
|
3 | for<'a> T: 'a,
| ^^
This fluent::borrowck_limitations_implies_static
note is incorrect. This is not a limitation of our current implementation. local
is actually required to be 'static
here, regardless of what we do.
It is only a limitation of there would be implied bounds on the bound variable, e.g in for<'a> &'a T: Trait
.
We should try to limit the note to such cases. Looking at the affected tests in #145041, most of the places we emit this note actually do not encounter any limitation of the borrowchecker and should continue to error.
estebankcompiler-errors
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemArea: Trait systemD-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.