Suggest return lifetime when there's only one named lifetime
This commit is contained in:
parent
7486b9c208
commit
795d307f10
3 changed files with 60 additions and 4 deletions
8
src/test/ui/suggestions/return-without-lifetime.rs
Normal file
8
src/test/ui/suggestions/return-without-lifetime.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
struct Thing<'a>(&'a ());
|
||||
|
||||
fn func1<'a>(_arg: &'a Thing) -> &() { unimplemented!() }
|
||||
//~^ ERROR missing lifetime specifier
|
||||
fn func2<'a>(_arg: &Thing<'a>) -> &() { unimplemented!() }
|
||||
//~^ ERROR missing lifetime specifier
|
||||
|
||||
fn main() {}
|
||||
19
src/test/ui/suggestions/return-without-lifetime.stderr
Normal file
19
src/test/ui/suggestions/return-without-lifetime.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/return-without-lifetime.rs:3:34
|
||||
|
|
||||
LL | fn func1<'a>(_arg: &'a Thing) -> &() { unimplemented!() }
|
||||
| ^ help: consider using the named lifetime `'a`: `&'a`
|
||||
|
|
||||
= help: this function's return type contains a borrowed value, but the signature does not say which one of `_arg`'s 2 lifetimes it is borrowed from
|
||||
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/return-without-lifetime.rs:5:35
|
||||
|
|
||||
LL | fn func2<'a>(_arg: &Thing<'a>) -> &() { unimplemented!() }
|
||||
| ^ help: consider using the named lifetime `'a`: `&'a`
|
||||
|
|
||||
= help: this function's return type contains a borrowed value, but the signature does not say which one of `_arg`'s 2 lifetimes it is borrowed from
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue