Closed
Description
Minimal reproducer:
struct Bug {}
impl Bug {
async fn buggy(&self) -> &'somelifetime str {
todo!()
}
}
In both stable (rustc 1.45.2 (d3fb005a3 2020-07-31)
) and nightly (rustc 1.47.0-nightly (663d2f5cd 2020-08-22)
) I get this error:
error[E0261]: use of undeclared lifetime name `'somelifetime`
--> src/lib.rs:3:31
|
3 | async fn buggy(&self) -> &'somelifetime str {
| ^^^^^^^^^^^^^ undeclared lifetime
|
help: consider introducing lifetime `'somelifetime` here
|
2 | impl<'somelifetime> Bug {
| ^^^^^^^^^^^^^^^
help: consider introducing lifetime `'somelifetime` here
|
3 | async fn buggy('somelifetime, &self) -> &'somelifetime str {
| ^^^^^^^^^^^^^^
If I make the method a top-level function, or if I drop the &self
parameter to make it an associated function, the issue goes away and rustc correctly suggests buggy<'somelifetime>()
.