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

[arithmetic_side_effects] false positive with string and derefs #14054

Open
JP-Ellis opened this issue Jan 21, 2025 · 0 comments
Open

[arithmetic_side_effects] false positive with string and derefs #14054

JP-Ellis opened this issue Jan 21, 2025 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@JP-Ellis
Copy link

JP-Ellis commented Jan 21, 2025

Summary

Concatenation of a String with &str when the &str is a String deref produces a false positive.

Lint Name

arithmetic_side_effects

Reproducer

Here's a minimal example that produces the error:

let x = String::new();
let y = String::new();
let z = x + &y;

assert_eq!(&z, "");

Playground

Version

rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: aarch64-apple-darwin
release: 1.84.0
LLVM version: 19.1.5

(also reproduced in Rust playground)

Additional Labels

No response

@JP-Ellis JP-Ellis added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jan 21, 2025
@JP-Ellis JP-Ellis changed the title [arithmetic_side_effects] false positive on repeated string concatenation [arithmetic_side_effects] false positive with string and derefs Jan 21, 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-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

1 participant