Skip to content

Commit 730f7b8

Browse files
committed
test: add a test and bless tests
1 parent 063ddf0 commit 730f7b8

11 files changed

Lines changed: 108 additions & 94 deletions

tests/ui/lint/dropping_copy_types-issue-125189-can-not-fixed.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | 0 => drop(y),
66
| |
77
| argument has type `i32`
88
|
9-
= note: use `let _ = ...` to ignore the expression or result
9+
= note: use `let _ = y` simply to ignore the expression or result
1010
note: the lint level is defined here
1111
--> $DIR/dropping_copy_types-issue-125189-can-not-fixed.rs:3:9
1212
|
@@ -21,7 +21,7 @@ LL | 1 => drop(z),
2121
| |
2222
| argument has type `i32`
2323
|
24-
= note: use `let _ = ...` to ignore the expression or result
24+
= note: use `let _ = z` simply to ignore the expression or result
2525

2626
error: calls to `std::mem::drop` with a value that implements `Copy` does nothing
2727
--> $DIR/dropping_copy_types-issue-125189-can-not-fixed.rs:11:14
@@ -31,7 +31,7 @@ LL | 2 => drop(3),
3131
| |
3232
| argument has type `i32`
3333
|
34-
= note: use `let _ = ...` to ignore the expression or result
34+
= note: use `let _ = 3` simply to ignore the expression or result
3535

3636
error: aborting due to 3 previous errors
3737

tests/ui/lint/dropping_copy_types-issue-125189.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: the lint level is defined here
1111
|
1212
LL | #![deny(dropping_copy_types)]
1313
| ^^^^^^^^^^^^^^^^^^^
14-
help: use `let _ = ...` to ignore the expression or result
14+
help: use `let _ = 3.2` simply to ignore the expression or result
1515
|
1616
LL - drop(3.2);
1717
LL + let _ = 3.2;
@@ -25,7 +25,7 @@ LL | drop(y);
2525
| |
2626
| argument has type `i32`
2727
|
28-
help: use `let _ = ...` to ignore the expression or result
28+
help: use `let _ = y` simply to ignore the expression or result
2929
|
3030
LL - drop(y);
3131
LL + let _ = y;

tests/ui/lint/dropping_copy_types-macros.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: the lint level is defined here
1111
|
1212
LL | #![deny(dropping_copy_types)]
1313
| ^^^^^^^^^^^^^^^^^^^
14-
help: use `let _ = ...` to ignore the expression or result
14+
help: use `let _ = writeln!(&mut msg, "test")` simply to ignore the expression or result
1515
|
1616
LL - drop(writeln!(&mut msg, "test"));
1717
LL + let _ = writeln!(&mut msg, "test");
@@ -25,7 +25,7 @@ LL | drop(format_args!("a"));
2525
| |
2626
| argument has type `Arguments<'_>`
2727
|
28-
help: use `let _ = ...` to ignore the expression or result
28+
help: use `let _ = format_args!("a")` simply to ignore the expression or result
2929
|
3030
LL - drop(format_args!("a"));
3131
LL + let _ = format_args!("a");

tests/ui/lint/dropping_copy_types.stderr

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: the lint level is defined here
1111
|
1212
LL | #![warn(dropping_copy_types)]
1313
| ^^^^^^^^^^^^^^^^^^^
14-
help: use `let _ = ...` to ignore the expression or result
14+
help: use `let _ = s1` simply to ignore the expression or result
1515
|
1616
LL - drop(s1);
1717
LL + let _ = s1;
@@ -25,13 +25,13 @@ LL | drop(s2);
2525
| |
2626
| argument has type `SomeStruct`
2727
|
28-
help: use `let _ = ...` to ignore the expression or result
28+
help: use `let _ = s2` simply to ignore the expression or result
2929
|
3030
LL - drop(s2);
3131
LL + let _ = s2;
3232
|
3333

34-
warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
34+
warning: calls to `std::mem::drop` with a reference does not drop the underline value
3535
--> $DIR/dropping_copy_types.rs:36:5
3636
|
3737
LL | drop(s3);
@@ -40,7 +40,7 @@ LL | drop(s3);
4040
| argument has type `&SomeStruct`
4141
|
4242
= note: `#[warn(dropping_references)]` on by default
43-
help: use `let _ = ...` to ignore the expression or result
43+
help: use `let _ = s3` simply to ignore the expression or result
4444
|
4545
LL - drop(s3);
4646
LL + let _ = s3;
@@ -54,49 +54,49 @@ LL | drop(s4);
5454
| |
5555
| argument has type `SomeStruct`
5656
|
57-
help: use `let _ = ...` to ignore the expression or result
57+
help: use `let _ = s4` simply to ignore the expression or result
5858
|
5959
LL - drop(s4);
6060
LL + let _ = s4;
6161
|
6262

63-
warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
63+
warning: calls to `std::mem::drop` with a reference does not drop the underline value
6464
--> $DIR/dropping_copy_types.rs:38:5
6565
|
6666
LL | drop(s5);
6767
| ^^^^^--^
6868
| |
6969
| argument has type `&SomeStruct`
7070
|
71-
help: use `let _ = ...` to ignore the expression or result
71+
help: use `let _ = s5` simply to ignore the expression or result
7272
|
7373
LL - drop(s5);
7474
LL + let _ = s5;
7575
|
7676

77-
warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
77+
warning: calls to `std::mem::drop` with a reference does not drop the underline value
7878
--> $DIR/dropping_copy_types.rs:50:5
7979
|
8080
LL | drop(a2);
8181
| ^^^^^--^
8282
| |
8383
| argument has type `&AnotherStruct`
8484
|
85-
help: use `let _ = ...` to ignore the expression or result
85+
help: use `let _ = a2` simply to ignore the expression or result
8686
|
8787
LL - drop(a2);
8888
LL + let _ = a2;
8989
|
9090

91-
warning: calls to `std::mem::drop` with a reference instead of an owned value does nothing
91+
warning: calls to `std::mem::drop` with a reference does not drop the underline value
9292
--> $DIR/dropping_copy_types.rs:52:5
9393
|
9494
LL | drop(a4);
9595
| ^^^^^--^
9696
| |
9797
| argument has type `&AnotherStruct`
9898
|
99-
help: use `let _ = ...` to ignore the expression or result
99+
help: use `let _ = a4` simply to ignore the expression or result
100100
|
101101
LL - drop(a4);
102102
LL + let _ = a4;
@@ -110,7 +110,7 @@ LL | drop(println_and(13));
110110
| |
111111
| argument has type `i32`
112112
|
113-
help: use `let _ = ...` to ignore the expression or result
113+
help: use `let _ = println_and(13)` simply to ignore the expression or result
114114
|
115115
LL - drop(println_and(13));
116116
LL + let _ = println_and(13);
@@ -124,7 +124,7 @@ LL | 3 if drop(println_and(14)) == () => (),
124124
| |
125125
| argument has type `i32`
126126
|
127-
= note: use `let _ = ...` to ignore the expression or result
127+
= note: use `let _ = println_and(14)` simply to ignore the expression or result
128128

129129
warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing
130130
--> $DIR/dropping_copy_types.rs:76:14
@@ -134,7 +134,7 @@ LL | 4 => drop(2),
134134
| |
135135
| argument has type `i32`
136136
|
137-
= note: use `let _ = ...` to ignore the expression or result
137+
= note: use `let _ = 2` simply to ignore the expression or result
138138

139139
warning: 10 warnings emitted
140140

tests/ui/lint/dropping_references-can-fixed.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: calls to `std::mem::drop` with a reference instead of an owned value does nothing
1+
error: calls to `std::mem::drop` with a reference does not drop the underline value
22
--> $DIR/dropping_references-can-fixed.rs:9:5
33
|
44
LL | drop(&SomeStruct);
@@ -11,105 +11,105 @@ note: the lint level is defined here
1111
|
1212
LL | #![deny(dropping_references)]
1313
| ^^^^^^^^^^^^^^^^^^^
14-
help: use `let _ = ...` to ignore the expression or result
14+
help: use `let _ = &SomeStruct` simply to ignore the expression or result
1515
|
1616
LL - drop(&SomeStruct);
1717
LL + let _ = &SomeStruct;
1818
|
1919

20-
error: calls to `std::mem::drop` with a reference instead of an owned value does nothing
20+
error: calls to `std::mem::drop` with a reference does not drop the underline value
2121
--> $DIR/dropping_references-can-fixed.rs:12:5
2222
|
2323
LL | drop(&owned1);
2424
| ^^^^^-------^
2525
| |
2626
| argument has type `&SomeStruct`
2727
|
28-
help: use `let _ = ...` to ignore the expression or result
28+
help: use `let _ = &owned1` simply to ignore the expression or result
2929
|
3030
LL - drop(&owned1);
3131
LL + let _ = &owned1;
3232
|
3333

34-
error: calls to `std::mem::drop` with a reference instead of an owned value does nothing
34+
error: calls to `std::mem::drop` with a reference does not drop the underline value
3535
--> $DIR/dropping_references-can-fixed.rs:13:5
3636
|
3737
LL | drop(&&owned1);
3838
| ^^^^^--------^
3939
| |
4040
| argument has type `&&SomeStruct`
4141
|
42-
help: use `let _ = ...` to ignore the expression or result
42+
help: use `let _ = &&owned1` simply to ignore the expression or result
4343
|
4444
LL - drop(&&owned1);
4545
LL + let _ = &&owned1;
4646
|
4747

48-
error: calls to `std::mem::drop` with a reference instead of an owned value does nothing
48+
error: calls to `std::mem::drop` with a reference does not drop the underline value
4949
--> $DIR/dropping_references-can-fixed.rs:14:5
5050
|
5151
LL | drop(&mut owned1);
5252
| ^^^^^-----------^
5353
| |
5454
| argument has type `&mut SomeStruct`
5555
|
56-
help: use `let _ = ...` to ignore the expression or result
56+
help: use `let _ = &mut owned1` simply to ignore the expression or result
5757
|
5858
LL - drop(&mut owned1);
5959
LL + let _ = &mut owned1;
6060
|
6161

62-
error: calls to `std::mem::drop` with a reference instead of an owned value does nothing
62+
error: calls to `std::mem::drop` with a reference does not drop the underline value
6363
--> $DIR/dropping_references-can-fixed.rs:18:5
6464
|
6565
LL | drop(reference1);
6666
| ^^^^^----------^
6767
| |
6868
| argument has type `&SomeStruct`
6969
|
70-
help: use `let _ = ...` to ignore the expression or result
70+
help: use `let _ = reference1` simply to ignore the expression or result
7171
|
7272
LL - drop(reference1);
7373
LL + let _ = reference1;
7474
|
7575

76-
error: calls to `std::mem::drop` with a reference instead of an owned value does nothing
76+
error: calls to `std::mem::drop` with a reference does not drop the underline value
7777
--> $DIR/dropping_references-can-fixed.rs:21:5
7878
|
7979
LL | drop(reference2);
8080
| ^^^^^----------^
8181
| |
8282
| argument has type `&mut SomeStruct`
8383
|
84-
help: use `let _ = ...` to ignore the expression or result
84+
help: use `let _ = reference2` simply to ignore the expression or result
8585
|
8686
LL - drop(reference2);
8787
LL + let _ = reference2;
8888
|
8989

90-
error: calls to `std::mem::drop` with a reference instead of an owned value does nothing
90+
error: calls to `std::mem::drop` with a reference does not drop the underline value
9191
--> $DIR/dropping_references-can-fixed.rs:24:5
9292
|
9393
LL | drop(reference3);
9494
| ^^^^^----------^
9595
| |
9696
| argument has type `&SomeStruct`
9797
|
98-
help: use `let _ = ...` to ignore the expression or result
98+
help: use `let _ = reference3` simply to ignore the expression or result
9999
|
100100
LL - drop(reference3);
101101
LL + let _ = reference3;
102102
|
103103

104-
error: calls to `std::mem::drop` with a reference instead of an owned value does nothing
104+
error: calls to `std::mem::drop` with a reference does not drop the underline value
105105
--> $DIR/dropping_references-can-fixed.rs:29:5
106106
|
107107
LL | drop(&val);
108108
| ^^^^^----^
109109
| |
110110
| argument has type `&T`
111111
|
112-
help: use `let _ = ...` to ignore the expression or result
112+
help: use `let _ = &val` simply to ignore the expression or result
113113
|
114114
LL - drop(&val);
115115
LL + let _ = &val;

tests/ui/lint/dropping_references.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,7 @@ fn issue112653() {
116116
Ok(())
117117
}
118118
}
119+
120+
fn issue155895() {
121+
let _ = drop(&SomeStruct); //~ WARN calls to `std::mem::drop`
122+
}

0 commit comments

Comments
 (0)