`assigning_clones` false negative with `str::to_string`

Open
#16,517 2 comments 0 reactions 1 assignee View on GitHub

@profetia is already working on this.

Since Feb 23, 2026.

Assessment

This issue has not been assessed yet.

Description

C-bug I-false-negative
Summary

The assigning_clones lint fails to trigger when assigning the result of str::to_string().

Lint Name

assigning_clones

Reproducer

I tried this code:

pub fn m1(a: &str) -> String {
    let mut b = String::new();
    b = a.to_string();
    b
}

https://godbolt.org/z/snT9h8ea6

I expected to see this happen:

warning: assigning the result of `str::to_string()` may be inefficient

Instead, this happened:

Lint did not trigger

Version
nightly
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/rust-clippy

All issues in rust-lang/rust-clippy

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.