Skip to content

"0 elided lifetimes" is confusing #30086

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

Closed
sanxiyn opened this issue Nov 27, 2015 · 3 comments
Closed

"0 elided lifetimes" is confusing #30086

sanxiyn opened this issue Nov 27, 2015 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Comments

@sanxiyn
Copy link
Member

sanxiyn commented Nov 27, 2015

fn a() -> &i32 {
    panic!();
}
fn b(x: i32) -> &i32 {
    panic!();
}
test.rs:1:11: 1:15 help: this function's return type contains a borrowed value,
but there is no value for it to be borrowed from
test.rs:4:17: 4:21 help: this function's return type contains a borrowed value,
but the signature does not say which one of `x`'s 0 elided lifetimes it is borrowed from

Help for a is reasonable, but help for b is not. See also #22760.

@sanxiyn sanxiyn added the A-diagnostics Area: Messages for errors, warnings, and lints label Nov 27, 2015
@arielb1
Copy link
Contributor

arielb1 commented Nov 27, 2015

@sanxiyn

What would you prefer for an error message? Same as the previous one?

@sanxiyn
Copy link
Member Author

sanxiyn commented Nov 28, 2015

Yes, same as the previous one would be an improvement.

@Manishearth Manishearth 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. E-help-wanted Call for participation: Help is requested to fix this issue. labels Nov 29, 2015
@Manishearth
Copy link
Member

Code:

fn report_elision_failure(

The fix is basically to check for n == 0 in any of the elision failure cases and then show the second warning unconditionally in such a case.

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 E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Projects
None yet
Development

No branches or pull requests

3 participants