Summary
unused_async_trait_impl should probably recognize ! type and not trigger on it
Lint Name
unused_async_trait_impl
Reproducer
I tried this code:
impl ReadAtAsync for ! {
async fn read_at<B>(&self, _buf: B, _offset: u64) -> io::Result<B>
where
AsyncReadBytes<B>: From<B>,
B: AsMut<[u8]> + Unpin + 'static,
{
unreachable!("Is never called")
}
}
I saw this happen:
warning: unused `async` for async trait impl function with no `.await` statements
--> crates/farmer/ab-farmer-components/src/lib.rs:150:5
|
150 | / async fn read_at<B>(&self, _buf: B, _offset: u64) -> io::Result<B>
151 | | where
152 | | AsyncReadBytes<B>: From<B>,
153 | | B: AsMut<[u8]> + Unpin + 'static,
154 | | {
155 | | unreachable!("Is never called")
156 | | }
| |_____^
|
= note: `std::future::ready` creates a `Future` which returns the value immediately when `poll`ed
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_async_trait_impl
= note: `-W clippy::unused-async-trait-impl` implied by `-W clippy::pedantic`
= help: to override `-W clippy::pedantic` add `#[allow(clippy::unused_async_trait_impl)]`
help: consider removing the `async` from this function and returning `impl Future<Output = io::Result<B>>` instead
|
150 ~ fn read_at<B>(&self, _buf: B, _offset: u64) -> impl Future<Output = io::Result<B>>
151 | where
...
154 | {
155 ~ std::future::ready(unreachable!("Is never called"))
|
Applying the suggestion leads to a different warning though:
--> crates/farmer/ab-farmer-components/src/lib.rs:155:9
|
155 | ready(unreachable!("Is never called"))
| ^^^^^ ------------------------------- any code following this expression is unreachable
| |
| unreachable call
|
= note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by default
I think it'd be better to special-case ! and not trigger this lint on it at all.
Version
rustc 1.98.0-nightly (e7815e522 2026-06-04)
binary: rustc
commit-hash: e7815e522ecc746592fee32f50478f521333b503
commit-date: 2026-06-04
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.6
Additional Labels
No response
Summary
unused_async_trait_implshould probably recognize!type and not trigger on itLint Name
unused_async_trait_impl
Reproducer
I tried this code:
I saw this happen:
Applying the suggestion leads to a different warning though:
I think it'd be better to special-case
!and not trigger this lint on it at all.Version
Additional Labels
No response