-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Uninhabited types have strange borrow-checking behavior, even behind references #146590
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.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.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-exhaustiveness-checkingRelating to exhaustiveness / usefulness checking of patternsRelating to exhaustiveness / usefulness checking of patternsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.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.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
I'm not sure if this is a bug or not.
I expected either both functions to compile or both functions to fail to compile. Instead, only the
failsfunction gives the following error:In my understanding, whether
&mut Neveris uninhabited is undecided. Therefore, since I'm only creating references toNever(as opposed to actually creatingNevervalues) I would think that I wouldn't get any special casing for uninhabited types. Thus, the current behavior seems wrong to me.Meta
Reproducible on the playground with version
1.92.0-nightly (2025-09-14 52618eb338609df44978)