-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why is replace_consts
enabled by default?
#2380
Comments
no, but there are none ;)
the const fns for integers are disputed, but the const fns for atomics are the way to go, the old constants were hacks that existed because of the lack of const fn. see also the discussion on the PR adding this lint #2344 |
FWIW I got this error on
This makes sense. |
Maybe what this lint needs is just better docs? The argument that |
So I think the main arguments are:
@petrochenkov you had strong thoughts about this. How would you document this? |
There are a few changes packed into this one. - Cut unnecessary negations (mostly shuffling if/else blocks) - Use isize::min_value() instead of std::isize::MIN, etc - rust-lang/rust-clippy#2380 - Rename some shadowing variables - Cut some unnecessary references - Use <struct>::default instead of Default::default - Update inclusive range syntax - Cut open import - Self - dyn trait
There are a few changes packed into this one. - Cut unnecessary negations (mostly shuffling if/else blocks) - Use isize::min_value() instead of std::isize::MIN, etc - rust-lang/rust-clippy#2380 - Rename some shadowing variables - Cut some unnecessary references - Use <struct>::default instead of Default::default - Update inclusive range syntax - Cut open import - Self - dyn trait
There are a few changes packed into this one. - Cut unnecessary negations (mostly shuffling if/else blocks) - Use isize::min_value() instead of std::isize::MIN, etc - rust-lang/rust-clippy#2380 - Rename some shadowing variables - Cut some unnecessary references - Use <struct>::default instead of Default::default - Update inclusive range syntax - Cut open import - Self - dyn trait
rust-lang/rust#68952 stabilized the As far as I can tell, that lint was meant to suggest to use the associated methods on the integer primitives, instead of the constants that have now been soft-deprecated in rust-lang/rust#68952. Although, the lint doesn't really provide a reason why one is better over the other. (Please correct me if I misunderstood that lint) The RFC also mentions a deprecation of the associated functions the lint is currently suggesting, so we might want to deprecate |
We can keep it but suggest moving from module consts to associated constant instead of to associated functions |
This could be closed now with #5380. |
The
replace_consts
lint is enabled inclippy-pedantic
by default.The docs hints that using consts is bad because
const fn
exists.This does not make any sense to me: why should
const fn
be preferred overconst
s? Are associated consts also bad?The text was updated successfully, but these errors were encountered: