Closed
Description
Summary
same as #7597 but with const
in impl
Lint Name
assertions_on_constants
Reproducer
I tried this code:
pub fn f() {
// const in impl
struct Features;
impl Features {
const FOO: bool = cfg!(not(feature = "foo"));
}
assert!(Features::FOO);
// const in trait
trait MyTrait {
const FOO: bool = cfg!(not(feature = "foo"));
}
impl MyTrait for () {}
assert!(<()>::FOO);
}
I expected to see this happen: cfg!()
is fixed
Instead, this happened:
warning: `assert!(true)` will be optimized out by the compiler
--> src/lib.rs:7:5
|
7 | assert!(Features::FOO);
| ^^^^^^^^^^^^^^^^^^^^^^
|
Version
rustc 1.74.0 (79e9716c9 2023-11-13)
binary: rustc
commit-hash: 79e9716c980570bfd1f666e3b16ac583f0168962
commit-date: 2023-11-13
host: x86_64-unknown-linux-gnu
release: 1.74.0
LLVM version: 17.0.4