Skip to content
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

Make clippy less noisy when asserting in const fn context #11963

Closed
StackOverflowExcept1on opened this issue Dec 15, 2023 · 3 comments
Closed

Comments

@StackOverflowExcept1on
Copy link
Contributor

Description

This code gets 2 warnings:

  1. constant is not used even if it is actually used in the const assert!()
  2. clippy found that the assertion is always true and can be optimized, although this code can be used as a replacement for static_assertions (which has not been updated for 4 years)
const X: usize = 5;

#[allow(dead_code, clippy::assertions_on_constants)]
const _: () = assert!(X % 5 == 0);
// ^ equivalent of static_assertions

Version

No response

Additional Labels

No response

@Jarcho
Copy link
Contributor

Jarcho commented Dec 17, 2023

dead_code is a rustc lint. The second part is fixed by #11966.

@StackOverflowExcept1on
Copy link
Contributor Author

Ok, I'll reopen issue in rust-lang/rust repo when clippy will be synced

@y21
Copy link
Member

y21 commented Dec 17, 2023

That dead_code one looks like rust-lang/rust#118424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants