Skip to content

clippy: fix str_to_string lint#10745

Open
xtqqczze wants to merge 3 commits intouutils:mainfrom
xtqqczze:clippy/str_to_string
Open

clippy: fix str_to_string lint#10745
xtqqczze wants to merge 3 commits intouutils:mainfrom
xtqqczze:clippy/str_to_string

Conversation

@xtqqczze
Copy link
Contributor

@xtqqczze xtqqczze commented Feb 5, 2026

@xtqqczze xtqqczze force-pushed the clippy/str_to_string branch from 092c8bb to 10531b9 Compare February 5, 2026 17:14
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/dd/no-allocate is now being skipped but was previously passing.

@xtqqczze xtqqczze force-pushed the clippy/str_to_string branch from 10531b9 to b4213cf Compare February 5, 2026 17:50
@xtqqczze xtqqczze marked this pull request as draft February 5, 2026 18:04
@xtqqczze xtqqczze force-pushed the clippy/str_to_string branch 2 times, most recently from 2b0391c to e77a1fa Compare February 5, 2026 19:50
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

@xtqqczze xtqqczze force-pushed the clippy/str_to_string branch 5 times, most recently from 9a6f51d to b13e432 Compare February 5, 2026 20:54
@nyurik
Copy link
Contributor

nyurik commented Feb 5, 2026

just fyi - i tried running it from my local clippy clone (on main) -- cargo dev lint <full-path-to-coreutils> -- --fix --allow-dirty --workspace --all-features after adding str_to_string = "warn" to Cargo.toml - tons of changes. Note that I ran it on top of my other PR, so your changes might be different. That said, I think it is better to merge #10704 first - otherwise it will have tons of conflicts, and my PR already had tons of manual work, whereas running the above fix command would do it automatically.

@xtqqczze xtqqczze force-pushed the clippy/str_to_string branch from b13e432 to f33e12d Compare February 5, 2026 21:50
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 5, 2026

Merging this PR will not alter performance

✅ 288 untouched benchmarks
⏩ 38 skipped benchmarks1


Comparing xtqqczze:clippy/str_to_string (4ffc772) with main (e7f2fd9)

Open in CodSpeed

Footnotes

  1. 38 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is now passing!

1 similar comment
@github-actions
Copy link

github-actions bot commented Feb 5, 2026

GNU testsuite comparison:

Congrats! The gnu test tests/basenc/bounded-memory is now passing!

@xtqqczze xtqqczze force-pushed the clippy/str_to_string branch from f33e12d to 904a96b Compare February 6, 2026 12:38
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/shuf/shuf-reservoir (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/sort/sort-stale-thread-mem (passes in this run but fails in the 'main' branch)

@xtqqczze

This comment was marked as outdated.

@github-actions
Copy link

github-actions bot commented Feb 7, 2026

GNU testsuite comparison:

GNU test failed: tests/timeout/timeout-group. tests/timeout/timeout-group is passing on 'main'. Maybe you have to rebase?

@xtqqczze xtqqczze force-pushed the clippy/str_to_string branch 3 times, most recently from 1e9dd47 to ffc210b Compare February 14, 2026 23:11
@xtqqczze xtqqczze force-pushed the clippy/str_to_string branch from ffc210b to 4ffc772 Compare February 14, 2026 23:14
@xtqqczze xtqqczze marked this pull request as ready for review February 14, 2026 23:26
@github-actions
Copy link

GNU testsuite comparison:

GNU test failed: tests/factor/t10. tests/factor/t10 is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/factor/t33. tests/factor/t33 is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/factor/t34. tests/factor/t34 is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/pr/bounded-memory (fails in this run but passes in the 'main' branch)
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.
Congrats! The gnu test tests/basenc/bounded-memory is now passing!

@xtqqczze
Copy link
Contributor Author

@sylvestre please merge this one soon to avoid more merge conflicts

@sylvestre
Copy link
Contributor

@xtqqczze why do we want this ?
i don't see the gain here

@xtqqczze
Copy link
Contributor Author

why do we want this ?

&str is already "string-like", so to_owned is slightly more expressive of the intent.

@sylvestre
Copy link
Contributor

honestly, i prefer to_string
i think it is easier for beginner to understand what it means

@xtqqczze
Copy link
Contributor Author

xtqqczze commented Feb 15, 2026

Essentially, ToString is designed to convert a value into a String and is implemented for types that implement the Display trait. However, when we specifically need an owned string, this conversion is unrelated to Display.

Using to_owned emphasizes the key point, it explicitly creates an owned string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants