Skip to content

"0 elided lifetimes" is confusing #30086

Closed
@sanxiyn

Description

@sanxiyn
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions