-
Notifications
You must be signed in to change notification settings - Fork 974
Closed
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEgood first issueIssues up for grabs, also good candidates for new rustfmt contributorsIssues up for grabs, also good candidates for new rustfmt contributors
Description
Clippy unfortunately warns about asserts whose conditions can be evaluated at compile-time even in inline const blocks. It's a known issue, it'll hopefully be solved at some point.
In the meantime, if one wishes to perform such compile-time asserts without disabling the lint globally, one can simply allow the offending lint:
fn main() {
const {
#![allow(clippy::assertions_on_constants)]
assert!(1 < 2);
}
}Unfortunately, running rustfmt on the above will simply remove the attribute (try it on the playground), resulting in:
fn main() {
const {
assert!(1 < 2);
}
}And then Clippy nags at us again :'(
With inline const blocks due to being stabilized for 1.79 (in 6 weeks), it would be nice to fix rustfmt to not eat their code away.
Meta
rustfmt version:
1.7.0-nightly (2024-05-03 d2d24e3)
Stargateur
Metadata
Metadata
Assignees
Labels
C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEgood first issueIssues up for grabs, also good candidates for new rustfmt contributorsIssues up for grabs, also good candidates for new rustfmt contributors