Skip to content
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

Ambiguous elided lifetime error claims non-elided lifetime is elided #29094

Closed
wthrowe opened this issue Oct 16, 2015 · 6 comments · Fixed by #42415
Closed

Ambiguous elided lifetime error claims non-elided lifetime is elided #29094

wthrowe opened this issue Oct 16, 2015 · 6 comments · Fixed by #42415
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@wthrowe
Copy link
Contributor

wthrowe commented Oct 16, 2015

struct Thing<'a>(&'a ());

fn func1<'a>(_arg: &'a Thing) -> &() { unimplemented!() }
fn func2<'a>(_arg: &Thing<'a>) -> &() { unimplemented!() }

gives

test.rs:3:34: 3:37 error: missing lifetime specifier [E0106]
test.rs:3 fn func1<'a>(_arg: &'a Thing) -> &() { unimplemented!() }
                                           ^~~
test.rs:3:34: 3:37 help: run `rustc --explain E0106` to see a detailed explanation
test.rs:3:34: 3:37 help: this function's return type contains a borrowed value, but the signature does not say which one of `_arg`'s 2 elided lifetimes it is borrowed from
test.rs:4:35: 4:38 error: missing lifetime specifier [E0106]
test.rs:4 fn func2<'a>(_arg: &Thing<'a>) -> &() { unimplemented!() }
                                            ^~~
test.rs:4:35: 4:38 help: run `rustc --explain E0106` to see a detailed explanation
test.rs:4:35: 4:38 help: this function's return type contains a borrowed value, but the signature does not say which one of `_arg`'s 2 elided lifetimes it is borrowed from
error: aborting due to 2 previous errors

Each time it refers to "_arg's 2 elided lifetimes", but in both cases only one of _arg's lifetimes is elided.

@arielb1
Copy link
Contributor

arielb1 commented Oct 16, 2015

We should just remove the "elided" - the rules work (and always worked) for all lifetimes.

@apasel422 apasel422 added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 28, 2015
@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum
Copy link
Member

E-easy/E-mentor. The code needs to be updated here to remove elided. A few tests will then fail, probably src/test/compile-fail/issue-26638.rs, src/test/compile-fail/issue-30255.rs, and src/test/compile-fail/lifetime-elision-return-type-requires-explicit-lifetime.rs which will need to be updated to remove the word elided as well.

Let us know if you'd like to work on this, or if you have any questions; we'll be happy to help.

@Mark-Simulacrum Mark-Simulacrum added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Jun 1, 2017
@stephen-lazaro
Copy link
Contributor

stephen-lazaro commented Jun 2, 2017

I'd be happy to take a shot at this over the weekend if no one else is interested, doesn't look like too much of a brain teaser. :)

@Mark-Simulacrum
Copy link
Member

Go ahead! Let us know if there's anything we can do to help you out.

./x.py test --incremental src/test/compile-fail is probably your best bet for compiling and testing in this case.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jun 5, 2017
Remove 'elided' from lifetime resolution error

Removes 'elided' from lifetime resolution errors
Removes 'elided' from relevant error messaging tests

This PR resolves rust-lang#29094

r? @Mark-Simulacrum
frewsxcv added a commit to frewsxcv/rust that referenced this issue Jun 7, 2017
Remove 'elided' from lifetime resolution error

Removes 'elided' from lifetime resolution errors
Removes 'elided' from relevant error messaging tests

This PR resolves rust-lang#29094

r? @Mark-Simulacrum
@Mark-Simulacrum
Copy link
Member

Reopening per #42415 (comment).

@Mark-Simulacrum Mark-Simulacrum added C-enhancement Category: An issue proposing an enhancement or a PR with one. and removed E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Jul 24, 2017
@steveklabnik
Copy link
Member

Triage: the error today:

Compiling playground v0.0.1 (/playground)
error[E0106]: missing lifetime specifier
 --> src/lib.rs:3:34
  |
3 | fn func1<'a>(_arg: &'a Thing) -> &() { unimplemented!() }
  |                                  ^ expected lifetime parameter
  |
  = 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
 --> src/lib.rs:4:35
  |
4 | fn func2<'a>(_arg: &Thing<'a>) -> &() { unimplemented!() }
  |                                   ^ expected lifetime parameter
  |
  = 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

It still does not suggest 'a, so keeping open as per @estebank 's comment.

pietroalbini added a commit to pietroalbini/rust that referenced this issue Mar 13, 2019
Suggest return lifetime when there's only one named lifetime

Fix rust-lang#29094.
Centril added a commit to Centril/rust that referenced this issue Mar 13, 2019
Suggest return lifetime when there's only one named lifetime

Fix rust-lang#29094.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Mar 14, 2019
Suggest return lifetime when there's only one named lifetime

Fix rust-lang#29094.
kennytm added a commit to kennytm/rust that referenced this issue Mar 15, 2019
Suggest return lifetime when there's only one named lifetime

Fix rust-lang#29094.
Centril added a commit to Centril/rust that referenced this issue Mar 16, 2019
Suggest return lifetime when there's only one named lifetime

Fix rust-lang#29094.
kennytm added a commit to kennytm/rust that referenced this issue Mar 16, 2019
Suggest return lifetime when there's only one named lifetime

Fix rust-lang#29094.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants