-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Closed
Copy link
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
#[derive(Copy, Clone)]
struct Invariant<'a>(std::marker::PhantomData<&'a mut &'a ()>);
impl<'a> Invariant<'a> {
fn lazy_dup(self) -> impl Fn() -> (Invariant<'a>, Self) {
|| (self, self)
}
}
error[E0308]: mismatched types
--> src/lib.rs:6:19
|
6 | || (self, self)
| ^^^^ lifetime mismatch
|
= note: expected type `Invariant<'static>`
found type `Invariant<'a>`
I didn't write 'static
anywhere - it comes from part of the implementation of impl Trait
, and Self
references lifetimes (from the impl
header) "indirectly", hiding them from impl Trait
logic.
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.