-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Description
fn foo(_: &'static u32) {}
fn unpromotable<T>(t: T) -> T { t }
fn main() {
foo(&unpromotable(5u32));
}
suggests
error[E0597]: borrowed value does not live long enough
--> src/main.rs:6:10
|
6 | foo(&unpromotable(5u32));
| ^^^^^^^^^^^^^^^^^^ - temporary value only lives until here
| |
| temporary value does not live long enough
|
= note: borrowed value must be valid for the static lifetime...
= note: consider using a `let` binding to increase its lifetime
but
let x = unpromotable(5u32);
foo(&x);
still won't give us a 'static
lifetime.
We should not emit the note
if the required lifetime is 'static
Instructions
- search for the
note
inside the source - I presume there's some code already checking for producing the "borrowed value must be valid for the static lifetime" message, find that code and bubble up the knowledge about that until you have it in the scope of the "consider using a
let
binding to increase its lifetime" message - Don't emit the message in that case
- This'll already fail a bunch of tests, I don't think you need any new tests. Running
./x.py test --stage 1 src/test/{ui,compile-fail} --bless
should succeed and give you a bunch of changes to commit. Check that all changes make sense and just commit them.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.