Skip to content

refactor: standardize on .to_owned() for message in linters#3569

Open
hippietrail wants to merge 7 commits into
Automattic:masterfrom
hippietrail:standardize_on_to_owned_for_linter_messages
Open

refactor: standardize on .to_owned() for message in linters#3569
hippietrail wants to merge 7 commits into
Automattic:masterfrom
hippietrail:standardize_on_to_owned_for_linter_messages

Conversation

@hippietrail
Copy link
Copy Markdown
Collaborator

Issues

N/A

Description

I was looking into handling a false positive in a linter I didn't write and noticed it used .to_owned() on the literal string set as the linter's message whereas I'd been using .to_string() in all of mine.

I asked an AI and it said in old versions of rust .to_owned() was faster but these days they're the same. But it still said that if I were to standardize on what that .to_owned() would be the better choice.

Some other calls to .to_string() on string literals also got changed by the search-and-replace I used but none resulted in errors or warnings so I let them be.

How Has This Been Tested?

cargo test

AI Disclosure

  • I am a human and didn't use any AI.
  • I used LLM features of my editor, but not an agent.
  • I used an AI agent interactively.
  • I am an agent or I got an agent to do the work autonomously.

I used Google Search's AI.

Checklist

  • I have performed a self-review of my own code
  • I have added tests to cover my changes
  • I have considered splitting this into smaller pull requests.

@hippietrail hippietrail added rust Pull requests that update Rust code linting labels Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linting rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants