-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.