Skip to content
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

Add #[must_use] to string/char transformation methods #89694

Merged
merged 2 commits into from
Oct 9, 2021

Conversation

jkugelman
Copy link
Contributor

These methods could be misconstrued as modifying their arguments instead of returning new values.

Where possible I made the note recommend a method that does mutate in place.

Parent issue: #89692

These methods could be misconstrued as modifying their arguments instead
of returning new values.

Where possible I made the note recommend a method that does mutate in
place.
@rust-highfive
Copy link
Collaborator

r? @joshtriplett

(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 Oct 9, 2021
@joshtriplett
Copy link
Member

r=me with the copy-paste issue corrected.

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
@joshtriplett
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 9, 2021

📌 Commit 2ec7588 has been approved by joshtriplett

@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 Oct 9, 2021
@joshtriplett joshtriplett added the relnotes Marks issues that should be documented in the release notes of the next release. label Oct 9, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 9, 2021
…s, r=joshtriplett

Add #[must_use] to string/char transformation methods

These methods could be misconstrued as modifying their arguments instead of returning new values.

Where possible I made the note recommend a method that does mutate in place.

Parent issue: rust-lang#89692
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 9, 2021
…askrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#88707 (String.split_terminator: Add an example when using a slice of chars)
 - rust-lang#89605 (Fix stabilization version for `bindings_after_at`)
 - rust-lang#89634 (rustc_driver: Enable the `WARN` log level by default)
 - rust-lang#89641 (make #[target_feature] work with `asm` register classes)
 - rust-lang#89678 (Fix minor std::thread documentation typo)
 - rust-lang#89684 (Fix asm docs typo)
 - rust-lang#89687 (Move `read2_abbreviated` function into read2.rs)
 - rust-lang#89693 (Add #[must_use] to stdin/stdout/stderr locks)
 - rust-lang#89694 (Add #[must_use] to string/char transformation methods)
 - rust-lang#89697 (Fix min LLVM version for bpf-types test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 827b540 into rust-lang:master Oct 9, 2021
@rustbot rustbot added this to the 1.57.0 milestone Oct 9, 2021
@jkugelman jkugelman deleted the must-use-string-transforms branch October 9, 2021 14:47
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 12, 2021
…b-methods, r=joshtriplett

Add #[must_use] to non-mutating verb methods

These are methods that could be misconstrued to mutate their input, similar to rust-lang#89694. I gave each one a different custom message.

I wrote that `upgrade` and `downgrade` don't modify the input pointers. Logically they don't, but technically they do...

Parent issue: rust-lang#89692

r? `@joshtriplett`
@@ -534,6 +538,7 @@ impl str {
/// [`make_ascii_uppercase`]: str::make_ascii_uppercase
/// [`to_uppercase`]: #method.to_uppercase
#[cfg(not(no_global_oom_handling))]
#[must_use = "to uppercase the value in-place, use `make_ascii_lowercase()`"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be make_ascii_uppercase().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. There was a similar copy-paste issue that was corrected, but this one wasn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitted PR #89814

the8472 added a commit to the8472/rust that referenced this pull request Oct 12, 2021
…b-methods, r=joshtriplett

Add #[must_use] to non-mutating verb methods

These are methods that could be misconstrued to mutate their input, similar to rust-lang#89694. I gave each one a different custom message.

I wrote that `upgrade` and `downgrade` don't modify the input pointers. Logically they don't, but technically they do...

Parent issue: rust-lang#89692

r? ``@joshtriplett``
the8472 added a commit to the8472/rust that referenced this pull request Oct 12, 2021
…b-methods, r=joshtriplett

Add #[must_use] to non-mutating verb methods

These are methods that could be misconstrued to mutate their input, similar to rust-lang#89694. I gave each one a different custom message.

I wrote that `upgrade` and `downgrade` don't modify the input pointers. Logically they don't, but technically they do...

Parent issue: rust-lang#89692

r? ```@joshtriplett```
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Oct 13, 2021
…s-typo, r=joshtriplett

Fix uppercase/lowercase error

Fix rust-lang#89694 (comment)

r? ``@joshtriplett``
the8472 added a commit to the8472/rust that referenced this pull request Oct 13, 2021
…s-typo, r=joshtriplett

Fix uppercase/lowercase error

Fix rust-lang#89694 (comment)

r? ```@joshtriplett```
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Oct 13, 2021
…s-typo, r=joshtriplett

Fix uppercase/lowercase error

Fix rust-lang#89694 (comment)

r? ````@joshtriplett````
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release. 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.

6 participants