Skip to content

Commit 4d8766c

Browse files
committed
Split must_use_unit test into an unfixable part
With the attribute refactor in rustc, making this case machine applicable is not easily possible anymore. This splits up the tests properly.
1 parent eda3e64 commit 4d8766c

File tree

5 files changed

+40
-33
lines changed

5 files changed

+40
-33
lines changed

tests/ui/must_use_unit.fixed

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,3 @@ fn main() {
2626
fn foo() {}
2727
);
2828
}
29-
30-
#[cfg_attr(all(), deprecated)]
31-
fn issue_12320() {}
32-
//~^ must_use_unit
33-
34-
#[cfg_attr(all(), deprecated, doc = "foo")]
35-
fn issue_12320_2() {}
36-
//~^ must_use_unit

tests/ui/must_use_unit.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,3 @@ fn main() {
2929
fn foo() {}
3030
);
3131
}
32-
33-
#[cfg_attr(all(), must_use, deprecated)]
34-
fn issue_12320() {}
35-
//~^ must_use_unit
36-
37-
#[cfg_attr(all(), deprecated, doc = "foo", must_use)]
38-
fn issue_12320_2() {}
39-
//~^ must_use_unit

tests/ui/must_use_unit.stderr

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,5 @@ LL | #[must_use = "With note"]
2525
LL | pub fn must_use_with_note() {}
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2727

28-
error: this unit-returning function has a `#[must_use]` attribute
29-
--> tests/ui/must_use_unit.rs:34:1
30-
|
31-
LL | #[cfg_attr(all(), must_use, deprecated)]
32-
| -------------------- help: change these attributes to: `deprecated`
33-
LL | fn issue_12320() {}
34-
| ^^^^^^^^^^^^^^^^
35-
36-
error: this unit-returning function has a `#[must_use]` attribute
37-
--> tests/ui/must_use_unit.rs:38:1
38-
|
39-
LL | #[cfg_attr(all(), deprecated, doc = "foo", must_use)]
40-
| --------------------------------- help: change these attributes to: `deprecated, doc = "foo"`
41-
LL | fn issue_12320_2() {}
42-
| ^^^^^^^^^^^^^^^^^^
43-
44-
error: aborting due to 5 previous errors
28+
error: aborting due to 3 previous errors
4529

tests/ui/must_use_unit_unfixable.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@no-rustfix
2+
3+
#[cfg_attr(all(), must_use, deprecated)]
4+
fn issue_12320() {}
5+
//~^ must_use_unit
6+
7+
#[cfg_attr(all(), deprecated, doc = "foo", must_use)]
8+
fn issue_12320_2() {}
9+
//~^ must_use_unit
10+
11+
fn main() {}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error: this unit-returning function has a `#[must_use]` attribute
2+
--> tests/ui/must_use_unit_unfixable.rs:4:1
3+
|
4+
LL | fn issue_12320() {}
5+
| ^^^^^^^^^^^^^^^^
6+
|
7+
help: remove `must_use`
8+
--> tests/ui/must_use_unit_unfixable.rs:3:19
9+
|
10+
LL | #[cfg_attr(all(), must_use, deprecated)]
11+
| ^^^^^^^^
12+
= note: `-D clippy::must-use-unit` implied by `-D warnings`
13+
= help: to override `-D warnings` add `#[allow(clippy::must_use_unit)]`
14+
15+
error: this unit-returning function has a `#[must_use]` attribute
16+
--> tests/ui/must_use_unit_unfixable.rs:8:1
17+
|
18+
LL | fn issue_12320_2() {}
19+
| ^^^^^^^^^^^^^^^^^^
20+
|
21+
help: remove `must_use`
22+
--> tests/ui/must_use_unit_unfixable.rs:7:44
23+
|
24+
LL | #[cfg_attr(all(), deprecated, doc = "foo", must_use)]
25+
| ^^^^^^^^
26+
27+
error: aborting due to 2 previous errors
28+

0 commit comments

Comments
 (0)