Closed
Description
Given this code:
pub struct A {
pub x: u32,
}
pub fn foo(y: u32) -> A {
A {
#[allow(unused_comparisons)]
x: if y < 0 { 1 } else { 2 },
}
}
no warnings, as expected, are generated:
$ rustc foo.rs --crate-type lib
Given this code (note the addition of #[inline]
) however:
pub struct A {
pub x: u32,
}
#[inline]
pub fn foo(y: u32) -> A {
A {
#[allow(unused_comparisons)]
x: if y < 0 { 1 } else { 2 },
}
}
a warning is generated:
$ rustc foo.rs --crate-type lib
warning: comparison is useless due to type limits
--> foo.rs:9:15
|
9 | x: if y < 0 { 1 } else { 2 },
| ^^^^^
|
= note: `#[warn(unused_comparisons)]` on by default
warning: 1 warning emitted