Skip to content

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

Closed
@wthrowe

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions