Emit single error for + use<'_> and don't suggest use<'static>#135052
Emit single error for + use<'_> and don't suggest use<'static>#135052estebank wants to merge 1 commit intorust-lang:mainfrom
+ use<'_> and don't suggest use<'static>#135052Conversation
|
|
||
| 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.
that's not true. This works fine: fn foo(x: &u8) -> impl Sized + use<'_> {}.
| 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.
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.
| ); | ||
| 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.
"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"
|
@rustbot author |
|
☔ The latest upstream changes (presumably #127541) made this pull request unmergeable. Please resolve the merge conflicts. |
```
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.
b37877c to
0b33708
Compare
|
☔ The latest upstream changes (presumably #139938) made this pull request unmergeable. Please resolve the merge conflicts. |
Fix #134194.
r? @compiler-errors