-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Patterns sometimes ignores lifetimes. #144312
Copy link
Copy link
Open
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh priorityT-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
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh priorityT-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
Projects
StatusShow more project fields
open/unblocked
Edit: This can cause UB. See #144312 (comment)
I tried this code:
I expected all of the
letstatements to cause compile errors, (or half of them, due to subtyping). Instead, all of the statements compile fine, except for the last one, which produced this compile error:I discovered this issue after some experimentation after @purplesyringa sent me this odd comment in the compiler:
rust/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
Lines 506 to 511 in c0b282f
Meta
Reproducible on the playground with version
1.90.0-nightly (2025-07-21 9748d87dc70a9a6725c5)@rustbot labels +A-patterns +A-borrow-checker +A-lifetimes