Ran into this warning and wanted to share my confusion with it. My confusion stems from the fact that this warning seems to be triggered inconsistently. Example of this
pub struct Example<const CONSTANT: u32>;
impl<const CONSTANT: u32> Example<CONSTANT> {
const DOESNT_CHANGE: usize = 3;
const ALSO_DOESNT_CHANGE: usize = Self::DOESNT_CHANGE;
pub fn does_trigger_warning(&self, i: usize) -> usize {
match i {
Self::ALSO_DOESNT_CHANGE => 0,
_ => 1
}
}
pub fn doesnt_trigger_warning(&self, i: usize) -> usize {
match i {
Self::DOESNT_CHANGE => 0,
_ => 1
}
}
pub fn also_doesnt_trigger_warning(&self, i: usize) -> usize {
if i == Self::ALSO_DOESNT_CHANGE {
0
} else {
1
}
}
}
The other thing that I found confusing was that the warning shows up on the declaration of DOESNT_CHANGE and not the usage (which is what caused the warning to appear).
I am using cargo 1.88.0-nightly (d811228b1 2025-04-15) and rustc 1.88.0-nightly (077cedc2a 2025-04-19).
Originally posted by @MorganBennetDev in #76200
Originally posted by @MorganBennetDev in #76200