-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Uplift the let_underscore
lints from clippy into rustc.
#97739
Commits on May 29, 2022
-
This lint checks for statements similar to `let _ = foo`, where `foo` is a type that implements `Drop`. These types of let statements cause the expression in them to be dropped immediately, instead of at the end of the scope. Such behavior can be surprizing, especially if you are relying on the value to be dropped at the end of the scope. Instead, the binding should be an underscore prefixed name (like `_unused`) or the value should explicitly be passed to `std::mem::drop()` if the value really should be dropped immediately.
Configuration menu - View commit details
-
Copy full SHA for 821b32b - Browse repository at this point
Copy the full SHA 821b32bView commit details
Commits on Jun 4, 2022
-
Similar to `let_underscore_drop`, this lint checks for statements similar to `let _ = foo`, where `foo` is a lock guard. These types of let statements are especially problematic because the lock gets released immediately, instead of at the end of the scope. This behavior is almost always the wrong thing.
Configuration menu - View commit details
-
Copy full SHA for ad7587f - Browse repository at this point
Copy the full SHA ad7587fView commit details -
Add
let_underscore_must_use
lint.Similar to `let_underscore_drop`, this lint checks for statements similar to `let _ = foo`, where `foo` is an expression marked `must_use`.
Configuration menu - View commit details
-
Copy full SHA for 758a9fd - Browse repository at this point
Copy the full SHA 758a9fdView commit details -
Move let_underscore tests to their own subfolder.
This was done to pass `tidy`.
Configuration menu - View commit details
-
Copy full SHA for 36b6309 - Browse repository at this point
Copy the full SHA 36b6309View commit details -
Allow
let_underscore_drop
andlet_underscore_must_use
by default.These lints are very noisy and are allow-by-default in clippy anyways. Hence, setting them to allow-by-default here makes more sense than warning constantly on these cases.
Configuration menu - View commit details
-
Copy full SHA for ae2ac3b - Browse repository at this point
Copy the full SHA ae2ac3bView commit details -
Show code suggestions in
let_undescore
lint messages.This commit uses `span_suggestion_verbose` to add what specific code changes can be done as suggested by the lint--in this case, either binding the expression to an unused variable or using `std::mem::drop` to drop the value explicitly.
Configuration menu - View commit details
-
Copy full SHA for eba6c78 - Browse repository at this point
Copy the full SHA eba6c78View commit details -
Set
let_underscore_lock
to Deny by default.Clippy sets this lint to Deny by default, and it having the lint be Deny is useful for when we test the lint against a Crater run.
Configuration menu - View commit details
-
Copy full SHA for 6b179e3 - Browse repository at this point
Copy the full SHA 6b179e3View commit details -
Configuration menu - View commit details
-
Copy full SHA for a7e2b3e - Browse repository at this point
Copy the full SHA a7e2b3eView commit details
Commits on Jun 5, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 7e485bf - Browse repository at this point
Copy the full SHA 7e485bfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1421cff - Browse repository at this point
Copy the full SHA 1421cffView commit details -
Configuration menu - View commit details
-
Copy full SHA for 30e8adb - Browse repository at this point
Copy the full SHA 30e8adbView commit details -
Bail out early if the type does not has a trivial Drop implementation.
If the type has a trivial Drop implementation, then it is probably irrelevant that the type was dropped immediately, since nothing important happens on drop. Hence, we can bail out early instead of doing some expensive checks.
Configuration menu - View commit details
-
Copy full SHA for e6b6678 - Browse repository at this point
Copy the full SHA e6b6678View commit details -
Use diagnostic items instead of hard coded paths for `let_underscore_…
…lock` Using diagnostic items avoids having to update the paths if the guard types ever get moved around for some reason. Additionally, it also greatly simplifies the `is_sync_lock` check.
Configuration menu - View commit details
-
Copy full SHA for 6342b58 - Browse repository at this point
Copy the full SHA 6342b58View commit details -
Use
check-pass
instead ofrun-pass
We don't actually care about running these programs, only checking the warnings they generate.
Configuration menu - View commit details
-
Copy full SHA for 11663b1 - Browse repository at this point
Copy the full SHA 11663b1View commit details -
Remove
let_underscore_must_use
The `let_underscore_must_use` lint was really only added because clippy included it, but it doesn't actually seem very useful.
Configuration menu - View commit details
-
Copy full SHA for b5b5b54 - Browse repository at this point
Copy the full SHA b5b5b54View commit details -
Add diagnostic items to MutexGuard and RwLock Guards
I forgot to add the diagnostic to the actual types in `std` earlier.
Configuration menu - View commit details
-
Copy full SHA for 321a598 - Browse repository at this point
Copy the full SHA 321a598View commit details -
Configuration menu - View commit details
-
Copy full SHA for 211feb1 - Browse repository at this point
Copy the full SHA 211feb1View commit details
Commits on Jun 9, 2022
-
Use
multipart_suggestion
to create an applicable suggestion.The "consider explicitly droping" can now suggest a machine applicable suggestion now.
Configuration menu - View commit details
-
Copy full SHA for cdf6606 - Browse repository at this point
Copy the full SHA cdf6606View commit details
Commits on Jun 11, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 7237e86 - Browse repository at this point
Copy the full SHA 7237e86View commit details -
Configuration menu - View commit details
-
Copy full SHA for b040666 - Browse repository at this point
Copy the full SHA b040666View commit details -
Make
let_underscore_drop
Deny by default.This is done so that we can check the noisiness of this lint in a Crater run. Note that when I built the compiler, I actually encountered lots of places where this lint will trigger and fail compilation, so I had to also set `RUSTFLAGS_NOT_BOOSTRAP` to `-A let_underscore_drop` when compiling to prevent that.
Configuration menu - View commit details
-
Copy full SHA for 8807c2d - Browse repository at this point
Copy the full SHA 8807c2dView commit details
Commits on Jun 17, 2022
-
Re-allow
let_underscore_drop
by default.This lint is way way too noisy to have it be `Deny` by default.
Configuration menu - View commit details
-
Copy full SHA for a9095ff - Browse repository at this point
Copy the full SHA a9095ffView commit details
Commits on Aug 4, 2022
-
Explain why let-underscoring a lock guard is incorrect.
Currently, the let_underscore_lock lint simply tells what is wrong, but not why it is wrong. We fix this by using a `MultiSpan` to explain specifically that doing `let _ = ` immediately drops the lock guard because it does not assign the lock guard to a binding.
Configuration menu - View commit details
-
Copy full SHA for a9f1b7b - Browse repository at this point
Copy the full SHA a9f1b7bView commit details -
I'm not really sure why this is nessecary to do, but the checks on the PR do not seem to work if do not do this.
Configuration menu - View commit details
-
Copy full SHA for d355ec9 - Browse repository at this point
Copy the full SHA d355ec9View commit details
Commits on Aug 5, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 76c90c3 - Browse repository at this point
Copy the full SHA 76c90c3View commit details