Open
Description
Code
trait UInt: Copy + From<u8> {}
impl UInt for u16 {}
trait Int: Copy {
type Unsigned: UInt;
fn as_unsigned(self) -> Self::Unsigned;
}
impl Int for i16 {
type Unsigned = u16;
fn as_unsigned(self) -> u16 {
self as _
}
}
fn priv_func<T: Int>(x: u8, y: T) -> (T::Unsigned, T::Unsigned) {
(T::Unsigned::from(x), y.as_unsigned())
}
pub fn pub_func(x: u8, y: i16) -> (u16, u16) {
priv_func(x, y)
}
Current output
warning: trait `UInt` is never used
--> src/lib.rs:1:7
|
1 | trait UInt: Copy + From<u8> {}
| ^^^^
|
= note: `#[warn(dead_code)]` on by default
Desired output
<empty>
Rationale and extra context
The false positive happens when a private trait is only used as type bound in another trait.
Other cases
No response
Rust Version
rustc 1.80.1 (3f5fd8dd4 2024-08-06)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-unknown-linux-gnu
release: 1.80.1
LLVM version: 18.1.7
Anything else?
No response