Skip to content

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

Merged
bors merged 2 commits into
rust-lang:masterfrom
jkugelman:must-use-string-transforms
Oct 9, 2021
Merged

Add #[must_use] to string/char transformation methods#89694
bors merged 2 commits into
rust-lang:masterfrom
jkugelman:must-use-string-transforms

Conversation

@jkugelman

Copy link
Copy Markdown
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
Copy Markdown
Contributor

r? @joshtriplett

(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 Oct 9, 2021
Comment threadlibrary/core/src/num/mod.rs Outdated
@joshtriplett

Copy link
Copy Markdown
Member

r=me with the copy-paste issue corrected.

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

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Oct 9, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 2ec7588 has been approved by joshtriplett

@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 Oct 9, 2021
@joshtriplettjoshtriplett 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:masterOct 9, 2021
@rustbotrustbot 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`
/// [`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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Fixrust-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
Fixrust-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
Fixrust-lang#89694 (comment)
r? ````@joshtriplett````
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotesMarks issues that should be documented in the release notes of the next release.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.

6 participants

@jkugelman@rust-highfive@joshtriplett@bors@Ltrlg@rustbot