Skip to content
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

string_to_string does not trigger inside a map function #14175

Open
MarkusTieger opened this issue Feb 8, 2025 · 0 comments
Open

string_to_string does not trigger inside a map function #14175

MarkusTieger opened this issue Feb 8, 2025 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@MarkusTieger
Copy link

MarkusTieger commented Feb 8, 2025

Summary

If you try to use String::to_string in a map function on an option, the lint does not trigger.

See the example below

Lint Name

string_to_string

Reproducer

I tried this code:

let variable1 = String::new();
let variable2 = Some(&variable1);
let variable3 = variable2.map(String::to_string);

I expected to see this happen:
That let variable3 = variable2.map(String::to_string); should be changed to let variable3 = variable2.cloned();

Instead, this happened:
nothing

Version

rustc 1.84.1 (e71f9a9a9 2025-01-27)
binary: rustc
commit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58
commit-date: 2025-01-27
host: x86_64-unknown-linux-gnu
release: 1.84.1
LLVM version: 19.1.5
@MarkusTieger MarkusTieger added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

No branches or pull requests

1 participant