Skip to content

Commit 099e2c0

Browse files
committed
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
2 parents 453242c + 7473f05 commit 099e2c0

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

Diff for: clippy_lints/src/methods/no_effect_replace.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub(super) fn check<'tcx>(
2525
&& param1 == param2.as_str()
2626
{
2727
span_lint(cx, NO_EFFECT_REPLACE, expr.span, "replacing text with itself");
28+
return;
2829
}
2930

3031
if SpanlessEq::new(cx).eq_expr(arg1, arg2) {

Diff for: tests/ui/no_effect_replace.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//@compile-flags: -Zdeduplicate-diagnostics=yes
2-
31
#![warn(clippy::no_effect_replace)]
42

53
fn main() {

Diff for: tests/ui/no_effect_replace.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: replacing text with itself
2-
--> tests/ui/no_effect_replace.rs:6:13
2+
--> tests/ui/no_effect_replace.rs:4:13
33
|
44
LL | let _ = "12345".replace('1', "1");
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,43 +8,43 @@ LL | let _ = "12345".replace('1', "1");
88
= help: to override `-D warnings` add `#[allow(clippy::no_effect_replace)]`
99

1010
error: replacing text with itself
11-
--> tests/ui/no_effect_replace.rs:9:13
11+
--> tests/ui/no_effect_replace.rs:7:13
1212
|
1313
LL | let _ = "12345".replace("12", "12");
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515

1616
error: replacing text with itself
17-
--> tests/ui/no_effect_replace.rs:11:13
17+
--> tests/ui/no_effect_replace.rs:9:13
1818
|
1919
LL | let _ = String::new().replace("12", "12");
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2121

2222
error: replacing text with itself
23-
--> tests/ui/no_effect_replace.rs:14:13
23+
--> tests/ui/no_effect_replace.rs:12:13
2424
|
2525
LL | let _ = "12345".replacen('1', "1", 1);
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2727

2828
error: replacing text with itself
29-
--> tests/ui/no_effect_replace.rs:16:13
29+
--> tests/ui/no_effect_replace.rs:14:13
3030
|
3131
LL | let _ = "12345".replacen("12", "12", 1);
3232
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3333

3434
error: replacing text with itself
35-
--> tests/ui/no_effect_replace.rs:18:13
35+
--> tests/ui/no_effect_replace.rs:16:13
3636
|
3737
LL | let _ = String::new().replacen("12", "12", 1);
3838
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3939

4040
error: replacing text with itself
41-
--> tests/ui/no_effect_replace.rs:25:13
41+
--> tests/ui/no_effect_replace.rs:23:13
4242
|
4343
LL | let _ = "hello".replace(&x.f(), &x.f());
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4545

4646
error: replacing text with itself
47-
--> tests/ui/no_effect_replace.rs:29:13
47+
--> tests/ui/no_effect_replace.rs:27:13
4848
|
4949
LL | let _ = "hello".replace(&y(), &y());
5050
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)