Skip to content

Commit d360eb5

Browse files
committed
move unfixable stuff to a separate file
1 parent b98252f commit d360eb5

File tree

4 files changed

+81
-15
lines changed

4 files changed

+81
-15
lines changed

tests/ui/mut_mut.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
extern crate proc_macros;
1313
use proc_macros::{external, inline_macros};
1414

15-
fn fun(x: &mut &mut u32) -> bool {
15+
fn fun(x: &mut &mut u32) {
1616
//~^ mut_mut
17-
**x > 0
1817
}
1918

2019
fn less_fun(x: *mut *mut u32) {
@@ -37,19 +36,17 @@ fn main() {
3736
//~^ mut_mut
3837
}
3938

40-
if fun(x) {
39+
{
4140
let y: &mut &mut u32 = &mut &mut 2;
4241
//~^ mut_mut
4342
//~| mut_mut
44-
**y + **x;
4543
}
4644

47-
if fun(x) {
45+
{
4846
let y: &mut &mut &mut u32 = &mut &mut &mut 2;
4947
//~^ mut_mut
5048
//~| mut_mut
5149
//~| mut_mut
52-
***y + **x;
5350
}
5451

5552
let mut z = inline!(&mut $(&mut 3u32));

tests/ui/mut_mut.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
error: generally you want to avoid `&mut &mut _` if possible
22
--> tests/ui/mut_mut.rs:15:11
33
|
4-
LL | fn fun(x: &mut &mut u32) -> bool {
4+
LL | fn fun(x: &mut &mut u32) {
55
| ^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::mut-mut` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::mut_mut)]`
99

1010
error: generally you want to avoid `&mut &mut _` if possible
11-
--> tests/ui/mut_mut.rs:33:17
11+
--> tests/ui/mut_mut.rs:32:17
1212
|
1313
LL | let mut x = &mut &mut 1u32;
1414
| ^^^^^^^^^^^^^^
1515

1616
error: generally you want to avoid `&mut &mut _` if possible
17-
--> tests/ui/mut_mut.rs:55:25
17+
--> tests/ui/mut_mut.rs:52:25
1818
|
1919
LL | let mut z = inline!(&mut $(&mut 3u32));
2020
| ^
2121
|
2222
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
2323

2424
error: this expression mutably borrows a mutable reference. Consider reborrowing
25-
--> tests/ui/mut_mut.rs:36:21
25+
--> tests/ui/mut_mut.rs:35:21
2626
|
2727
LL | let mut y = &mut x;
2828
| ^^^^^^
2929

3030
error: generally you want to avoid `&mut &mut _` if possible
31-
--> tests/ui/mut_mut.rs:41:32
31+
--> tests/ui/mut_mut.rs:40:32
3232
|
3333
LL | let y: &mut &mut u32 = &mut &mut 2;
3434
| ^^^^^^^^^^^
3535

3636
error: generally you want to avoid `&mut &mut _` if possible
37-
--> tests/ui/mut_mut.rs:41:16
37+
--> tests/ui/mut_mut.rs:40:16
3838
|
3939
LL | let y: &mut &mut u32 = &mut &mut 2;
4040
| ^^^^^^^^^^^^^
4141

4242
error: generally you want to avoid `&mut &mut _` if possible
43-
--> tests/ui/mut_mut.rs:48:37
43+
--> tests/ui/mut_mut.rs:46:37
4444
|
4545
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
4646
| ^^^^^^^^^^^^^^^^
4747

4848
error: generally you want to avoid `&mut &mut _` if possible
49-
--> tests/ui/mut_mut.rs:48:16
49+
--> tests/ui/mut_mut.rs:46:16
5050
|
5151
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
5252
| ^^^^^^^^^^^^^^^^^^
5353

5454
error: generally you want to avoid `&mut &mut _` if possible
55-
--> tests/ui/mut_mut.rs:48:21
55+
--> tests/ui/mut_mut.rs:46:21
5656
|
5757
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
5858
| ^^^^^^^^^^^^^

tests/ui/mut_mut_unfixable.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//@no-rustfix
2+
3+
#![warn(clippy::mut_mut)]
4+
#![allow(unused)]
5+
#![expect(clippy::no_effect)]
6+
7+
//! removing the extra `&mut`s will break the derefs
8+
9+
fn fun(x: &mut &mut u32) -> bool {
10+
//~^ mut_mut
11+
**x > 0
12+
}
13+
14+
fn main() {
15+
let mut x = &mut &mut 1u32;
16+
//~^ mut_mut
17+
{
18+
let mut y = &mut x;
19+
//~^ mut_mut
20+
***y + **x;
21+
}
22+
23+
if fun(x) {
24+
let y = &mut &mut 2;
25+
//~^ mut_mut
26+
**y + **x;
27+
}
28+
29+
if fun(x) {
30+
let y = &mut &mut &mut 2;
31+
//~^ mut_mut
32+
***y + **x;
33+
}
34+
}

tests/ui/mut_mut_unfixable.stderr

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error: generally you want to avoid `&mut &mut _` if possible
2+
--> tests/ui/mut_mut_unfixable.rs:9:11
3+
|
4+
LL | fn fun(x: &mut &mut u32) -> bool {
5+
| ^^^^^^^^^^^^^
6+
|
7+
= note: `-D clippy::mut-mut` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::mut_mut)]`
9+
10+
error: generally you want to avoid `&mut &mut _` if possible
11+
--> tests/ui/mut_mut_unfixable.rs:15:17
12+
|
13+
LL | let mut x = &mut &mut 1u32;
14+
| ^^^^^^^^^^^^^^
15+
16+
error: this expression mutably borrows a mutable reference. Consider reborrowing
17+
--> tests/ui/mut_mut_unfixable.rs:18:21
18+
|
19+
LL | let mut y = &mut x;
20+
| ^^^^^^
21+
22+
error: generally you want to avoid `&mut &mut _` if possible
23+
--> tests/ui/mut_mut_unfixable.rs:24:17
24+
|
25+
LL | let y = &mut &mut 2;
26+
| ^^^^^^^^^^^
27+
28+
error: generally you want to avoid `&mut &mut _` if possible
29+
--> tests/ui/mut_mut_unfixable.rs:30:17
30+
|
31+
LL | let y = &mut &mut &mut 2;
32+
| ^^^^^^^^^^^^^^^^
33+
34+
error: aborting due to 5 previous errors
35+

0 commit comments

Comments
 (0)