-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Lint must_use on mem::replace #71256
Conversation
This adds a hint on `mem::replace`, "if you don't need the old value, you can just assign the new value directly". This is in similar spirit to the `must_use` on `ManuallyDrop::take`.
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Huh, I didn't expect that this would already affect code in the compiler itself. I'll look into it. |
OK, github-actions CI/PR passed now. |
I'm ok with the code changes. Couldn't find whether the lint is only warn-by-default. If it is, then r=me, after the nitpick about the test. |
Yes, it is a warning by default -- the way that I check is with
I addressed the test nitpick too, so... @bors r=estebank |
📌 Commit 7fca9f8 has been approved by |
Lint must_use on mem::replace This adds a hint on `mem::replace`, "if you don't need the old value, you can just assign the new value directly". This is in similar spirit to the `must_use` on `ManuallyDrop::take`.
fails since cargo doesn't use the result somewhere, (fixing it) |
@bors r- |
fix mem replace unused `mem::replace` will be linted as must_use, so modifying this. This is currently blocking rust-lang/rust#71256
I see, cargo already had a warning in the normal build, but |
the blocking pr is now merged @bors r=estebank |
📌 Commit 7fca9f8 has been approved by |
Do I need to update the cargo submodule too? Or are you handling that elsewhere? |
Uh right we probably have to update cargo first |
@bors r- |
I'll post a cargo update tomorrowish after the beta branch. There are several big changes that I don't feel comfortable sliding into beta at the last moment. |
📌 Commit 7fca9f8 has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#71256 (Lint must_use on mem::replace) - rust-lang#71350 (Error code explanation extra check) - rust-lang#71369 (allow wasm32 compilation of librustc_data_structures/profiling.rs) - rust-lang#71400 (proc_macro::is_available()) - rust-lang#71440 (Implement `Copy` for `AllocErr`) Failed merges: r? @ghost
This adds a hint on
mem::replace
, "if you don't need the old value,you can just assign the new value directly". This is in similar spirit
to the
must_use
onManuallyDrop::take
.