Skip to content

Commit

Permalink
Split must_use_unit test into an unfixable part
Browse files Browse the repository at this point in the history
With the attribute refactor in rustc, making this case machine applicable is not
easily possible anymore. This splits up the tests properly.
  • Loading branch information
flip1995 committed Feb 27, 2025
1 parent 53a1ff7 commit 28555d1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 43 deletions.
8 changes: 0 additions & 8 deletions tests/ui/must_use_unit.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,3 @@ fn main() {
fn foo() {}
);
}

#[cfg_attr(all(), deprecated)]
fn issue_12320() {}
//~^ must_use_unit

#[cfg_attr(all(), deprecated, doc = "foo")]
fn issue_12320_2() {}
//~^ must_use_unit
8 changes: 0 additions & 8 deletions tests/ui/must_use_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,3 @@ fn main() {
fn foo() {}
);
}

#[cfg_attr(all(), must_use, deprecated)]
fn issue_12320() {}
//~^ must_use_unit

#[cfg_attr(all(), deprecated, doc = "foo", must_use)]
fn issue_12320_2() {}
//~^ must_use_unit
18 changes: 1 addition & 17 deletions tests/ui/must_use_unit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,5 @@ LL | #[must_use = "With note"]
LL | pub fn must_use_with_note() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: this unit-returning function has a `#[must_use]` attribute
--> tests/ui/must_use_unit.rs:34:1
|
LL | #[cfg_attr(all(), must_use, deprecated)]
| -------------------- help: change these attributes to: `deprecated`
LL | fn issue_12320() {}
| ^^^^^^^^^^^^^^^^

error: this unit-returning function has a `#[must_use]` attribute
--> tests/ui/must_use_unit.rs:38:1
|
LL | #[cfg_attr(all(), deprecated, doc = "foo", must_use)]
| --------------------------------- help: change these attributes to: `deprecated, doc = "foo"`
LL | fn issue_12320_2() {}
| ^^^^^^^^^^^^^^^^^^

error: aborting due to 5 previous errors
error: aborting due to 3 previous errors

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//@aux-build:proc_macros.rs
//@no-rustfix

#![warn(clippy::must_use_unit)]
#![allow(clippy::unused_unit)]

#[cfg_attr(all(), must_use, deprecated)]
fn issue_12320() {}
//~^ must_use_unit

#[cfg_attr(all(), deprecated, doc = "foo", must_use)]
fn issue_12320_2() {}
//~^ must_use_unit

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
error: this unit-returning function has a `#[must_use]` attribute
--> tests/ui/must_use_unit_12320.rs:8:1
--> tests/ui/must_use_unit_unfixable.rs:4:1
|
LL | fn issue_12320() {}
| ^^^^^^^^^^^^^^^^
|
help: remove `must_use`
--> tests/ui/must_use_unit_12320.rs:7:19
--> tests/ui/must_use_unit_unfixable.rs:3:19
|
LL | #[cfg_attr(all(), must_use, deprecated)]
| ^^^^^^^^
= note: `-D clippy::double-must-use` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::double_must_use)]`
= note: `-D clippy::must-use-unit` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::must_use_unit)]`

error: this unit-returning function has a `#[must_use]` attribute
--> tests/ui/must_use_unit_12320.rs:11:1
--> tests/ui/must_use_unit_unfixable.rs:8:1
|
LL | fn issue_12320_2() {}
| ^^^^^^^^^^^^^^^^^^
|
help: remove `must_use`
--> tests/ui/must_use_unit_12320.rs:10:44
--> tests/ui/must_use_unit_unfixable.rs:7:44
|
LL | #[cfg_attr(all(), deprecated, doc = "foo", must_use)]
| ^^^^^^^^
Expand Down

0 comments on commit 28555d1

Please sign in to comment.