Skip to content

Commit 70650de

Browse files
committed
Auto merge of rust-lang#13241 - alex-semenyuk:fix_double_must_use, r=xFrednet
Fix confusing message in double_must_use lint Close rust-lang#13003 As mentioned at rust-lang#13003 it isn't quite clear what it means "an empty `#[must_use]` attribute" so clarify it changelog: [none]
2 parents 2c0f318 + 9948b42 commit 70650de

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

clippy_lints/src/functions/must_use.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ fn check_needless_must_use(
129129
cx,
130130
DOUBLE_MUST_USE,
131131
fn_header_span,
132-
"this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`",
132+
"this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`",
133133
None,
134-
"either add some descriptive text or remove the attribute",
134+
"either add some descriptive message or remove the attribute",
135135
);
136136
}
137137
}

tests/ui/double_must_use.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33

44
#[must_use]
55
pub fn must_use_result() -> Result<(), ()> {
6-
//~^ ERROR: this function has an empty `#[must_use]` attribute, but returns a type already
6+
//~^ ERROR: this function has a `#[must_use]` attribute with no message, but returns a type already
77
unimplemented!();
88
}
99

1010
#[must_use]
1111
pub fn must_use_tuple() -> (Result<(), ()>, u8) {
12-
//~^ ERROR: this function has an empty `#[must_use]` attribute, but returns a type already
12+
//~^ ERROR: this function has a `#[must_use]` attribute with no message, but returns a type already
1313
unimplemented!();
1414
}
1515

1616
#[must_use]
1717
pub fn must_use_array() -> [Result<(), ()>; 1] {
18-
//~^ ERROR: this function has an empty `#[must_use]` attribute, but returns a type already
18+
//~^ ERROR: this function has a `#[must_use]` attribute with no message, but returns a type already
1919
unimplemented!();
2020
}
2121

@@ -32,7 +32,7 @@ async fn async_must_use() -> usize {
3232

3333
#[must_use]
3434
async fn async_must_use_result() -> Result<(), ()> {
35-
//~^ ERROR: this function has an empty `#[must_use]` attribute, but returns a type already
35+
//~^ ERROR: this function has a `#[must_use]` attribute with no message, but returns a type already
3636
Ok(())
3737
}
3838

tests/ui/double_must_use.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`
1+
error: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
22
--> tests/ui/double_must_use.rs:5:1
33
|
44
LL | pub fn must_use_result() -> Result<(), ()> {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: either add some descriptive text or remove the attribute
7+
= help: either add some descriptive message or remove the attribute
88
= note: `-D clippy::double-must-use` implied by `-D warnings`
99
= help: to override `-D warnings` add `#[allow(clippy::double_must_use)]`
1010

11-
error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`
11+
error: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
1212
--> tests/ui/double_must_use.rs:11:1
1313
|
1414
LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) {
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1616
|
17-
= help: either add some descriptive text or remove the attribute
17+
= help: either add some descriptive message or remove the attribute
1818

19-
error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`
19+
error: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
2020
--> tests/ui/double_must_use.rs:17:1
2121
|
2222
LL | pub fn must_use_array() -> [Result<(), ()>; 1] {
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424
|
25-
= help: either add some descriptive text or remove the attribute
25+
= help: either add some descriptive message or remove the attribute
2626

27-
error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`
27+
error: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
2828
--> tests/ui/double_must_use.rs:34:1
2929
|
3030
LL | async fn async_must_use_result() -> Result<(), ()> {
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3232
|
33-
= help: either add some descriptive text or remove the attribute
33+
= help: either add some descriptive message or remove the attribute
3434

3535
error: aborting due to 4 previous errors
3636

0 commit comments

Comments
 (0)