-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Conversation
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 has picked a reviewer for you, use r? to override) |
r=me with the copy-paste issue corrected. |
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
@bors r+ |
📌 Commit 2ec7588 has been approved by |
…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
…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
…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()`"] |
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submitted PR #89814
…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``
…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```
…s-typo, r=joshtriplett Fix uppercase/lowercase error Fix rust-lang#89694 (comment) r? ``@joshtriplett``
…s-typo, r=joshtriplett Fix uppercase/lowercase error Fix rust-lang#89694 (comment) r? ```@joshtriplett```
…s-typo, r=joshtriplett Fix uppercase/lowercase error Fix rust-lang#89694 (comment) r? ````@joshtriplett````
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