-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Sized check inconsistently checks/ignores lifetimes #156770
Copy link
Copy link
Open
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-trait-systemArea: Trait systemArea: Trait systemC-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.
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-trait-systemArea: Trait systemArea: Trait systemC-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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
This issue is similar to #156694.
I'm not sure if this is a bug.
In the above code, I've specified that
T::Assoc<'a>: Sized. However, the code tries to useT::Assoc<'b>: Sized. A function argument needs to beSized, which makes it a bit weird thatworkscompiles. However, once we've accepted the argument, moving the variable somehow requiresSizedin a way such that the compiler checks lifetimes, makingfailscompile error. This is strange.In the above code, I've again specified that
T::Assoc<'a>: Sized, but requiredT::Assoc<'b>: Sized. Normally, declaring a closure to return a type requires that type to implementSized, but that check seems to ignore lifetimes. Even calling the closure and putting the result into a variable is allowed. However, for some reason, moving that result into a second variable causes the compiler to check the lifetimes. This is strange.cc @lcnr
Meta
Reproducible on the playground with version
1.97.0-nightly (2026-05-19 e50aa6fba4e63ab34c72)