-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)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-member-constraints`#[feature(member_constraints)]``#[feature(member_constraints)]`C-bugCategory: This is a bug.Category: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
struct Inv<'a>(*mut &'a ());
fn mk<'m>() -> (Inv<'m>, Inv<'m>) {
loop {}
}
fn ok<'a, 'b: 'a>() -> (impl Sized + use<'a>, impl Sized + use<'b>) {
mk()
}
fn err<'a, 'b: 'a>() -> (impl Sized + use<'b>, impl Sized + use<'a>) {
mk()
}this fails with
error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds
--> src/lib.rs:9:5
|
8 | fn err<'a, 'b: 'a>() -> (impl Sized + use<'b>, impl Sized + use<'a>) {
| -- -------------------- opaque type defined here
| |
| hidden type `Inv<'b>` captures the lifetime `'b` as defined here
9 | mk()
| ^^^^
|
help: add `'b` to the `use<...>` bound to explicitly capture it
|
8 | fn err<'a, 'b: 'a>() -> (impl Sized + use<'b>, impl Sized + use<'a, 'b>) {
| ++++We've got 'm member ['a, 'static] and 'm member ['b, 'static]. The final region chosen for 'm depends on the order in which we apply these constraints:
'm member ['b, 'static]chooses'b'm member ['a, 'static]as'a: 'bdoes not hold, this has to choose'static- we end up with
'm = 'staticwhich satisfies both member constraints
and alternatively:
'm member ['a, 'static]chooses'a'm member ['b, 'static]can still choose'bas'b: 'aholds- we end up with
'm = 'bwhich means that'm member ['a, 'static]does not hold
Fixing this is not too difficult, we can "simply" apply member constraints for each member region until we reach a fixpoint. we can implement this separately once #139587 landed.
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)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-member-constraints`#[feature(member_constraints)]``#[feature(member_constraints)]`C-bugCategory: This is a bug.Category: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.