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

Add static_assert attribute #6568

Closed
emberian opened this issue May 17, 2013 · 2 comments
Closed

Add static_assert attribute #6568

emberian opened this issue May 17, 2013 · 2 comments
Labels
A-attributes Area: #[attributes(..)] A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@emberian
Copy link
Member

 @graydon | if someone wants a cute task
 @graydon | I would be fond of an attribute called #[static_assert]
 @graydon | that, when applied to a static bool, halts compilation if the bool evaluates to false.
 @graydon | and is an error (or ignored) anywhere else
 @graydon | maybe optionally #[static_assert("why this is important")]
@emberian
Copy link
Member Author

@graydon could you provide some examples so I can test what I have so far?

@emberian
Copy link
Member Author

Fixed by #6670

flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 22, 2021
…lip1995

Fix: redundant_pattern_matching drop order

Fixes rust-lang#5746

A note about the change in drop order is added when the scrutinee (or any temporary in the expression) isn't known to be safe to drop in any order (i.e. doesn't implement the `Drop` trait, or contain such a type). There is a whitelist for some `std` types, but it's incomplete. Currently just `Vec<_>`, `Box<_>`, `Rc<_>` and `Arc<_>`, but only if the contained type is also safe to drop in any order.

Another lint for when the drop order changes could be added as allowed by default, but the drop order requirement is pretty subtle in this case. I think the note added to the lint should be enough to make someone think before applying the change.

changelog: Added a note to `redundant_pattern_matching` when the change in drop order might matter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: #[attributes(..)] A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

1 participant