Repository navigation
Closed
Closed
Copy link
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.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-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Code
extern crate futures;
use futures::executor::block_on;
use futures::future::join;
fn test() {
let a = async {};
let b = async { loop {} };
block_on(join(a, b));
}Current output
warning: unreachable expression
--> src/lib.rs:5:11
|
5 | fn test() {
| ___________^
6 | | let a = async {};
7 | |
8 | | let b = async { loop {} };
9 | |
10 | | block_on(join(a, b));
| | -------------------- any code following this expression is unreachable
11 | | }
| |_^ unreachable expression
|
note: this expression has type `((), !)`, which is uninhabited
--> src/lib.rs:10:5
|
10 | block_on(join(a, b));
| ^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by defaultDesired output
Rationale and extra context
I don't think this lint should trigger at all in this case, since it's the last expression in the function. It doesn't trigger in the same way if there is anything after it, and the block_on and join seem to be load bearing.
Other cases
Rust Version
Nightly:
> rustc --version --verbose
rustc 1.93.0-nightly (518b42830 2025-11-16)
binary: rustc
commit-hash: 518b428304e0008859cb1fd81d1ac20efb2a064a
commit-date: 2025-11-16
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.5
Beta:
> rustc --version --verbose
rustc 1.92.0-beta.3 (f3f12444a 2025-11-09)
binary: rustc
commit-hash: f3f12444a017add0468f683f3a10656d29438a05
commit-date: 2025-11-09
host: x86_64-unknown-linux-gnu
release: 1.92.0-beta.3
LLVM version: 21.1.3Anything else?
No response
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.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-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Activity
ryanavella commentedon Nov 17, 2025
The lint also fires for
match block_on(join(a, b)) {}despite the exhaustive match on the uninhabited type.clubby789 commentedon Nov 17, 2025
searched nightlies: from nightly-2025-08-01 to nightly-2025-10-16
regressed nightly: nightly-2025-10-13
searched commit range: be0ade2...2300c2a
regressed commit: ff6dc92
bisected with cargo-bisect-rustc v0.6.11
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
clubby789 commentedon Nov 17, 2025
#142390 cc @cjgillot - I guess the warning is correct but the 'unreachable expression' span is wrong. Seems like it's using the span of the implicit
_0 = const ()return value assignment, which is that of the whole functionAuto merge of #149044 - clubby789:implicit-return-span, r=cjgillot
Auto merge of #149044 - clubby789:implicit-return-span, r=cjgillot
Auto merge of #149044 - clubby789:implicit-return-span, r=cjgillot
Auto merge of #149044 - clubby789:implicit-return-span, r=cjgillot
Auto merge of #149044 - clubby789:implicit-return-span, r=cjgillot
Auto merge of rust-lang#149044 - clubby789:implicit-return-span, r=cj…
Auto merge of #149044 - clubby789:implicit-return-span, r=cjgillot
Auto merge of #149044 - clubby789:implicit-return-span, r=cjgillot
Auto merge of #149044 - clubby789:implicit-return-span, r=cjgillot
Auto merge of #149044 - clubby789:implicit-return-span, r=cjgillot