-
Notifications
You must be signed in to change notification settings - Fork 13k
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
use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into() #53563
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
Motivation: rust-lang/rust-clippy#2972 |
Thanks! @bors r+ rollup |
📌 Commit e97ccd89d8b2d5f5c9038a293f19a474358b3404 has been approved by |
Another option would be to make But following the breadcrumbs… Lines 2160 to 2165 in 70c33bb
Lines 2200 to 2204 in 70c33bb
Lines 206 to 208 in 70c33bb
…it seems we could try to add a Lines 731 to 733 in 70c33bb
|
Mh yes, I also wondered if there was some way to have some sort of shortcut. Is there some way to only emit the check if we know the input of the function is a constant and is guaranteed to be optimized out (by always taking the |
I think this would require dependent types, or all the functions I quoted to be const fn Edit: Oh, and Edit2: Well… Lines 1686 to 1688 in a9d4967
Lines 365 to 370 in a9d4967
Lines 164 to 171 in a9d4967
|
@matthiaskrgr The check for empty allocation is already done by |
Oh, that's interesting! When I tried setting a very high (9999....) or very low (1, 0) inline threshold on godbolt I still can't get String::from() to be inlined though. 😕 |
We’ll just have to add |
Rollup of 10 pull requests Successful merges: - #53418 (Mark some suggestions as MachineApplicable) - #53431 (Moved some feature gate ui tests to correct location) - #53442 (Update version of rls-data used with save-analysis) - #53504 (Set applicability for more suggestions.) - #53541 (Fix missing impl trait display as ret type) - #53544 (Point at the trait argument when using unboxed closure) - #53558 (Normalize source line and column numbers.) - #53562 (Lament the invincibility of the Turbofish) - #53574 (Suggest direct raw-pointer dereference) - #53585 (Remove super old comment on function that parses items) Failed merges: - #53472 (Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.) - #53563 (use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()) r? @ghost
☔ The latest upstream changes (presumably #53607) made this pull request unmergeable. Please resolve the merge conflicts. |
…owned() or "".into()
rebased |
@bors r+ rollup |
📌 Commit ede1f7d has been approved by |
use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()
Rollup of 16 pull requests Successful merges: - #53311 (Window Mutex: Document that we properly initialize the SRWLock) - #53503 (Discourage overuse of mem::forget) - #53545 (Fix #50865: ICE on impl-trait returning functions reaching private items) - #53559 (add macro check for lint) - #53562 (Lament the invincibility of the Turbofish) - #53563 (use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()) - #53592 (docs: minor stylistic changes to str/string docs) - #53594 (Update RELEASES.md to include clippy-preview) - #53600 (Fix a grammatical mistake in "expected generic arguments" errors) - #53614 (update nomicon and book) - #53617 (tidy: Stop requiring a license header) - #53618 (Add missing fmt examples) - #53636 (Prefer `.nth(n)` over `.skip(n).next()`.) - #53644 (Use SmallVec for SmallCStr) - #53664 (Remove unnecessary closure in rustc_mir/build/mod.rs) - #53666 (Added rustc_codegen_llvm to compiler documentation.)
No description provided.