-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit single error for + use<'_>
and don't suggest use<'static>
#135052
base: master
Are you sure you want to change the base?
Conversation
@@ -3118,7 +3121,9 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { | |||
} | |||
} | |||
|
|||
if num_params == 0 { | |||
if in_precise_capture { | |||
err.note("`use<...>` precise captures list require a named lifetime"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's not true. This works fine: fn foo(x: &u8) -> impl Sized + use<'_> {}
.
@@ -4,33 +4,26 @@ error[E0106]: missing lifetime specifier | |||
LL | fn no_elided_lt() -> impl Sized + use<'_> {} | |||
| ^^ expected named lifetime parameter | |||
| | |||
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably at least keep some explanation that justifies why '_
isn't valid without another lifetime which it can resolve to in the inputs.
``` error[E0106]: missing lifetime specifier --> $DIR/bad-lifetimes.rs:1:39 | LL | fn no_elided_lt() -> impl Sized + use<'_> {} | ^^ expected named lifetime parameter | help: consider introducing a named lifetime parameter | LL | fn no_elided_lt<'a>() -> impl Sized + use<'a> {} | ++++ ~~ ``` Fix rust-lang#134194.
); | ||
if in_precise_capture { | ||
err.note( | ||
"this function's return type specifies a borrowed `use<'_>` with an elided \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"a borrowed use<'_>
" feels really awkward. I think this can be a bit more direct. Perhaps something like:
"cannot capture elided lifetime with use<'_>
when there is no lifetime in scope to capture"
Fix #134194.
r? @compiler-errors