-
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 clippy::{drop,forget}_{ref,copy}
lints
#109732
Conversation
r? @TaKO8Ki (rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
026278d
to
5c6fed5
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some cases in rustc, fun (can't wait for clippy to finally work on rustc^^)
5c6fed5
to
e87ceee
Compare
This comment has been minimized.
This comment has been minimized.
d7ccffc
to
88a9561
Compare
This comment has been minimized.
This comment has been minimized.
8183b99
to
c3edde2
Compare
c3edde2
to
fad236f
Compare
Nominating for T-lang approval, as it seems to be the norm. @rustbot label: +I-lang-nominated |
@bors r=davidtwco |
🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. |
☀️ Test successful - checks-actions |
1 similar comment
☀️ Test successful - checks-actions |
Finished benchmarking commit (077fc26): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 659.774s -> 659.596s (-0.03%) |
Remove useless drop of copy type ### What does this PR try to resolve? This PR aims to remove useless drop of copy type to clear warnings that reported after rust-lang/rust#109732 ``` warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing --> src/cargo/core/compiler/job_queue/mod.rs:1048:21 | 1048 | drop(write!( | ______________________^____- | | _____________________| | || 1049 | || message, 1050 | || " (run `{command} --{args}` to apply {suggestions})" 1051 | || )) | ||_____________________-^ | |______________________| | argument has type `Result<(), std::fmt::Error>` | = note: use `let _ = ...` to ignore the expression or result = note: `#[warn(drop_copy)]` on by default ``` ### How should we test and review this PR? ```bash cargo build && cargo test # without any warnings ``` ### Additional information None
…lints, r=fee1-dead Rename `{drop,forget}_{copy,ref}` lints to more consistent naming This PR renames previous uplifted lints in rust-lang#109732 to more consistent naming. I followed the renaming done [here](rust-lang#53224) and also advocated in this [clippy issue](rust-lang/rust-clippy#2845): - `drop_copy` to `dropping_copy_types` - `forget_copy` to `forgetting_copy_types` - `drop_ref` to `dropping_references` - `forget_ref` to `forgetting_references`
…fee1-dead Rename `{drop,forget}_{copy,ref}` lints to more consistent naming This PR renames previous uplifted lints in rust-lang/rust#109732 to more consistent naming. I followed the renaming done [here](rust-lang/rust#53224) and also advocated in this [clippy issue](rust-lang/rust-clippy#2845): - `drop_copy` to `dropping_copy_types` - `forget_copy` to `forgetting_copy_types` - `drop_ref` to `dropping_references` - `forget_ref` to `forgetting_references`
Followed up of d36e390d8176babedcf326581959958d447170cd See rust-lang/rust#109732 (comment) for more details. Co-authored-by: Jethro Beekman <[email protected]>
…fee1-dead Rename `{drop,forget}_{copy,ref}` lints to more consistent naming This PR renames previous uplifted lints in rust-lang/rust#109732 to more consistent naming. I followed the renaming done [here](rust-lang/rust#53224) and also advocated in this [clippy issue](rust-lang/rust-clippy#2845): - `drop_copy` to `dropping_copy_types` - `forget_copy` to `forgetting_copy_types` - `drop_ref` to `dropping_references` - `forget_ref` to `forgetting_references`
This PR aims at uplifting the
clippy::drop_ref
,clippy::drop_copy
,clippy::forget_ref
andclippy::forget_copy
lints.Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted.
drop_ref
andforget_ref
The
drop_ref
andforget_ref
lint checks for calls tostd::mem::drop
orstd::mem::forget
with a reference instead of an owned value.Example
Explanation
Calling
drop
orforget
on a reference will only drop the reference itself, which is a no-op. It will not call thedrop
orforget
method on the underlying referenced value, which is likely what was intended.drop_copy
andforget_copy
The
drop_copy
andforget_copy
lint checks for calls tostd::mem::forget
orstd::mem::drop
with a value that derives the Copy trait.Example
Explanation
Calling
std::mem::forget
does nothing for types that implement Copy since the value will be copied and moved into the function on invocation.Followed the instructions for uplift a clippy describe here: #99696 (review)
cc @m-ou-se (as T-libs-api leader because the uplifting was discussed in a recent meeting)