-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
1.92.0 warns about unreachable code, but that code can't be removed without type errors #152559
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-false-positiveLint: False positive (should not have fired).Lint: False positive (should not have fired).L-unreachable_codeLint: unreachable_codeLint: unreachable_codeP-highHigh priorityHigh priorityT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.L-false-positiveLint: False positive (should not have fired).Lint: False positive (should not have fired).L-unreachable_codeLint: unreachable_codeLint: unreachable_codeP-highHigh priorityHigh priorityT-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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I tried this code:
And rustc raises an "unreachable expression" warning. This seems reasonable. So I remove that line:
I expected to see this happen:
Instead, this happened: rustc seems to simultaneously indicate that path is unreachable, AND some expression is needed there to satisfy the type-checker.
Is there really no way to write the(Sorry, I shouldn't have asked. Didn't mean to nerd-snipe.)runfunction without invoking#[allow(unreachable_code)]? That seems odd.Meta
rustc --version --verbose:(Happens on any stable version >= 1.92.0; and also on nightly 2026-02-11)