#17043·rust-clippy

`redundant_type_annotations` conflicts with `let_underscore_untyped`

Author: nazar-pcCreated May 20, 2026Updated Sep 18, 2026
LabelsC-bugI-false-positiveL-restriction

Description

With both lints enabled, it is not possible to satisfy clippy:

rust
#![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);
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=0dc0724547b4228d8abfe78442a8f493

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