rust-lang / rust-lang/rust-clippy
`redundant_type_annotations` conflicts with `let_underscore_untyped`
Open
@saberoueslati is already working on this.
Since Sep 18, 2026.
C-bug
I-false-positive
L-restriction
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Description
With both lints enabled, it is not possible to satisfy clippy:
#![warn(clippy::let_underscore_untyped)]
#![warn(clippy::redundant_type_annotations)]
pub struct U24([u8; 3]);
impl U24 {
pub fn from_u32(v: u32) -> Self {
let b = v.to_le_bytes();
assert!(
(v << u8::BITS) >> u8::BITS == v,
"Input value exceeds 24 bits"
);
Self([b[0], b[1], b[2]])
}
pub fn to_u32(self) -> u32 {
let [a, b, c] = self.0;
u32::from_le_bytes([a, b, c, 0])
}
}
#[expect(dead_code)]
fn u24_from_u32_overflow_panics_in_debug() {
let _: U24 = U24::from_u32(0x0100_0000);
}
Type is specified:
warning: redundant type annotation
--> src/lib.rs:24:5
|
24 | let _: U24 = U24::from_u32(0x0100_0000);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_type_annotations
note: the lint level is defined here
--> src/lib.rs:2:9
|
2 | #![warn(clippy::redundant_type_annotations)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Or not:
warning: non-binding `let` without a type annotation
--> src/lib.rs:24:5
|
24 | let _ = U24::from_u32(0x0100_0000);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider adding a type annotation
--> src/lib.rs:24:10
|
24 | let _ = U24::from_u32(0x0100_0000);
| ^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_underscore_untyped
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![warn(clippy::let_underscore_untyped)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This doesn't happen when the type has generics though.
Version
rustc 1.97.0-nightly (20de910db 2026-05-02)
binary: rustc
commit-hash: 20de910db49d3476ccf49ea79a4b22e2b5dface0
commit-date: 2026-05-02
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4
Additional Labels
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.