-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Add lint for zero-size non-default arrays #148475
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
base: master
Are you sure you want to change the base?
Add lint for zero-size non-default arrays #148475
Conversation
This introduces a new lint for detecting usage of `[T; 0]: Default` where `T: !Default`. It includes checks in `check_item` and `check_expr` methods to enforce the linting rules.
|
r? @davidtwco rustbot has assigned @davidtwco. Use |
This comment has been minimized.
This comment has been minimized.
|
Please excuse the syntax errors - I am running the code on Github as I don't want to run it locally. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
Please add tests for this in a (new) first commit, bless them there, then bless them in the second one with the changes made here, to show that this works. |
|
Reminder, once the PR becomes ready for a review, use |
|
Please see #145457 (comment) ; libs-api is not sure if we want to warn about this. |
This introduces a new lint for detecting usage of
[T; 0]: DefaultwhereT: !Default. It includes checks incheck_itemandcheck_exprmethods to enforce the linting rules. This is in light of @WaffleLapkin's analysis in #145457 that it might be OK for this impl to break for the[T; N]: Default where T: Defaultimpl. If the Rust community disagrees, this PR will close.Please review as I am a new contributor and may have made many mistakes.