Auto merge of #12443 - cookie-s:noeffectreoplace-fix-dup-diags, r=Alexendoo

[`no_effect_replace`]: Fix duplicate diagnostics

Relates to #12379

Fixes `no_effect_replace` duplicate diagnostics

---

changelog: [`no_effect_replace`]: Fix duplicate diagnostics
This commit is contained in:
bors 2024-03-09 13:02:47 +00:00
commit 099e2c0033
3 changed files with 9 additions and 10 deletions

View file

@ -25,6 +25,7 @@ pub(super) fn check<'tcx>(
&& param1 == param2.as_str() && param1 == param2.as_str()
{ {
span_lint(cx, NO_EFFECT_REPLACE, expr.span, "replacing text with itself"); span_lint(cx, NO_EFFECT_REPLACE, expr.span, "replacing text with itself");
return;
} }
if SpanlessEq::new(cx).eq_expr(arg1, arg2) { if SpanlessEq::new(cx).eq_expr(arg1, arg2) {

View file

@ -1,5 +1,3 @@
//@compile-flags: -Zdeduplicate-diagnostics=yes
#![warn(clippy::no_effect_replace)] #![warn(clippy::no_effect_replace)]
fn main() { fn main() {

View file

@ -1,5 +1,5 @@
error: replacing text with itself error: replacing text with itself
--> tests/ui/no_effect_replace.rs:6:13 --> tests/ui/no_effect_replace.rs:4:13
| |
LL | let _ = "12345".replace('1', "1"); LL | let _ = "12345".replace('1', "1");
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -8,43 +8,43 @@ LL | let _ = "12345".replace('1', "1");
= help: to override `-D warnings` add `#[allow(clippy::no_effect_replace)]` = help: to override `-D warnings` add `#[allow(clippy::no_effect_replace)]`
error: replacing text with itself error: replacing text with itself
--> tests/ui/no_effect_replace.rs:9:13 --> tests/ui/no_effect_replace.rs:7:13
| |
LL | let _ = "12345".replace("12", "12"); LL | let _ = "12345".replace("12", "12");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: replacing text with itself error: replacing text with itself
--> tests/ui/no_effect_replace.rs:11:13 --> tests/ui/no_effect_replace.rs:9:13
| |
LL | let _ = String::new().replace("12", "12"); LL | let _ = String::new().replace("12", "12");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: replacing text with itself error: replacing text with itself
--> tests/ui/no_effect_replace.rs:14:13 --> tests/ui/no_effect_replace.rs:12:13
| |
LL | let _ = "12345".replacen('1', "1", 1); LL | let _ = "12345".replacen('1', "1", 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: replacing text with itself error: replacing text with itself
--> tests/ui/no_effect_replace.rs:16:13 --> tests/ui/no_effect_replace.rs:14:13
| |
LL | let _ = "12345".replacen("12", "12", 1); LL | let _ = "12345".replacen("12", "12", 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: replacing text with itself error: replacing text with itself
--> tests/ui/no_effect_replace.rs:18:13 --> tests/ui/no_effect_replace.rs:16:13
| |
LL | let _ = String::new().replacen("12", "12", 1); LL | let _ = String::new().replacen("12", "12", 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: replacing text with itself error: replacing text with itself
--> tests/ui/no_effect_replace.rs:25:13 --> tests/ui/no_effect_replace.rs:23:13
| |
LL | let _ = "hello".replace(&x.f(), &x.f()); LL | let _ = "hello".replace(&x.f(), &x.f());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: replacing text with itself error: replacing text with itself
--> tests/ui/no_effect_replace.rs:29:13 --> tests/ui/no_effect_replace.rs:27:13
| |
LL | let _ = "hello".replace(&y(), &y()); LL | let _ = "hello".replace(&y(), &y());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^