Open
Description
Code
pub fn f() -> impl Iterator<Item = ()> {
todo!() as core::iter::Empty<()>
}
Current output
warning: unreachable expression
--> src/lib.rs:2:5
|
2 | todo!() as core::iter::Empty<()>
| -------^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| unreachable expression
| any code following this expression is unreachable
|
= note: `#[warn(unreachable_code)]` on by default
warning: `playground` (lib) generated 1 warning
Desired output
No warning
Rationale and extra context
Using todo!()
with a return type that is impl
currently causes a type error. Using as
to give it a specific type fixes that but brings this incorrect warning message.
as T
by itself shouldn't really be considered an expression.
Other cases
No response
Rust Version
rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: aarch64-apple-darwin
release: 1.77.2
LLVM version: 17.0.6
rustc 1.78.0-beta.6 (27011d5dc 2024-04-09)
binary: rustc
commit-hash: 27011d5dc09a8d1ac2289d024f54ecac9fc70d47
commit-date: 2024-04-09
host: aarch64-apple-darwin
release: 1.78.0-beta.6
LLVM version: 18.1.2
rustc 1.79.0-nightly (aa067fb98 2024-04-10)
binary: rustc
commit-hash: aa067fb984d36462548bb785da221bfaf38253f0
commit-date: 2024-04-10
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.3
Anything else?
No response