Skip to content

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Apr 17, 2020

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
Contributor

r? @kennytm

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

@rust-highfive rust-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
Member Author

cuviper commented Apr 17, 2020

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

@cuviper
Copy link
Member Author

cuviper commented Apr 17, 2020

OK, github-actions CI/PR passed now.

@kennytm kennytm requested a review from estebank April 19, 2020 15:52
@estebank
Copy link
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
Member Author

cuviper commented Apr 20, 2020

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
Copy link
Collaborator

bors commented Apr 20, 2020

📌 Commit 7fca9f8 has been approved by estebank

@bors bors 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

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

@Dylan-DPC-zz
Copy link

@bors r-

@bors bors 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
@kennytm kennytm 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
Member Author

cuviper commented Apr 20, 2020

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

the blocking pr is now merged

@bors r=estebank

@bors
Copy link
Collaborator

bors commented Apr 20, 2020

📌 Commit 7fca9f8 has been approved by estebank

@bors bors 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
Member Author

cuviper commented Apr 20, 2020

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

@Dylan-DPC-zz
Copy link

Uh right we probably have to update cargo first

@Dylan-DPC-zz
Copy link

@bors r-

@bors bors 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-zz Dylan-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
Contributor

ehuss commented Apr 20, 2020

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
Member Author

cuviper commented Apr 22, 2020

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

@bors r=estebank

@bors
Copy link
Collaborator

bors commented Apr 22, 2020

📌 Commit 7fca9f8 has been approved by estebank

@bors bors 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:master Apr 23, 2020
@cuviper cuviper deleted the must_use_replace branch May 30, 2020 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: 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