Skip to content

Lint must_use on mem::replace - #71256

Merged
bors merged 3 commits into
rust-lang:masterfrom
cuviper:must_use_replace
Apr 23, 2020
Merged

Lint must_use on mem::replace#71256
bors merged 3 commits into
rust-lang:masterfrom
cuviper:must_use_replace

Conversation

@cuviper

Copy link
Copy Markdown
Member

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.

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`.
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @kennytm

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 17, 2020
@rust-highfive

This comment has been minimized.

@cuviper

Copy link
Copy Markdown
MemberAuthor

Huh, I didn't expect that this would already affect code in the compiler itself. I'll look into it.

@cuviper

Copy link
Copy Markdown
MemberAuthor

OK, github-actions CI/PR passed now.

Comment threadsrc/test/ui/issues/issue-23611-enum-swap-in-drop.rs Outdated
@kennytm
kennytm requested a review from estebankApril 19, 2020 15:52
@estebank

Copy link
Copy Markdown
Contributor

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.

@cuviper

Copy link
Copy Markdown
MemberAuthor

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 -Whelp:

$ rustc -Whelp | grep must_use
unused-must-use warn unused result of a type flagged as `#[must_use]`

I addressed the test nitpick too, so...

@bors r=estebank

@bors

bors commented Apr 20, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 7fca9f8 has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 20, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 20, 2020
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`.
@Dylan-DPC-zz

Copy link
Copy Markdown

fails since cargo doesn't use the result somewhere, (fixing it)

@Dylan-DPC-zz

Copy link
Copy Markdown

@bors r-

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 20, 2020
@kennytmkennytm added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 20, 2020
bors added a commit to rust-lang/cargo that referenced this pull request Apr 20, 2020
fix mem replace unused
`mem::replace` will be linted as must_use, so modifying this.
This is currently blocking rust-lang/rust#71256
@cuviper

Copy link
Copy Markdown
MemberAuthor

I see, cargo already had a warning in the normal build, but #![cfg_attr(test, deny(warnings))] stopped it in full CI. Thanks for going ahead with that fix!

@Dylan-DPC-zz

Copy link
Copy Markdown

the blocking pr is now merged

@bors r=estebank

@bors

bors commented Apr 20, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 7fca9f8 has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Apr 20, 2020
@cuviper

Copy link
Copy Markdown
MemberAuthor

Do I need to update the cargo submodule too? Or are you handling that elsewhere?

@Dylan-DPC-zz

Copy link
Copy Markdown

Uh right we probably have to update cargo first

@Dylan-DPC-zz

Copy link
Copy Markdown

@bors r-

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 20, 2020
@Dylan-DPC-zzDylan-DPC-zz added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 20, 2020
@ehuss

Copy link
Copy Markdown
Contributor

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.

@cuviper

Copy link
Copy Markdown
MemberAuthor

Cargo was updated in #71402, so let's give this another shot.

@bors r=estebank

@bors

bors commented Apr 22, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 7fca9f8 has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Apr 22, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2020
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
@bors
bors merged commit 10e47f5 into rust-lang:masterApr 23, 2020
@cuviper
cuviper deleted the must_use_replace branch May 30, 2020 21:55
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@cuviper@rust-highfive@estebank@bors@Dylan-DPC-zz@ehuss@kennytm