2 ms·
Well if that it all this could be solved by rust by having a "floating_point_usage" (or similar) lint which normally defaults to "allow" but for kernel devs de
by dathinab 6y ago
Well if that it all this could be solved by rust by having a "floating_point_usage" (or similar) lint
which normally defaults to "allow" but for kernel
devs defaults to "error" (which could be done through an option in the target spec, which as a side note is also what defines if you have hard,soft or no fp support). (there are probably better solution but this one should be the easiest).
- ssokolow 6y agoThere's actually a lint specifically intended for that already. `float_arithmetic`: https://rust-lang.github.io/rust-clippy/master/#float_arithmetic https://rust-lang.github.io/rust-clippy/master/#float_arithm... # What it does Checks for float arithmetic. # Why is this bad For some embedded systems or kernel development, it can be useful to rule out floating-point numbers.
- dathinab 6y agoThanks, nice, but for the kernel use case it would need to be part of rustc.
- zaarn 6y agoSimply install clippy and call "clippy-driver" instead of "rustc", which will handle this. Clippy is largely the lints that haven't either made it into rustc or are fairly edge-case-y.
- littlestymaar 6y agoWhy? The Rust-for-Linux team already made Clippy a requirement for Rust kernel code. For niche configuration that are really project-specific like this, it makes total sense to use external tooling to ensure the guidelines are respected, it doesn't need to be the compiler enforcing these guidelines.