Fix confusing message in double_must_use lint

This commit is contained in:
Alexey Semenyuk 2024-08-09 01:35:28 +05:00
parent 377d72ae8b
commit 9948b423a0
3 changed files with 14 additions and 14 deletions

View File

@ -129,9 +129,9 @@ fn check_needless_must_use(
cx,
DOUBLE_MUST_USE,
fn_header_span,
"this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`",
"this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`",
None,
"either add some descriptive text or remove the attribute",
"either add some descriptive message or remove the attribute",
);
}
}

View File

@ -3,19 +3,19 @@
#[must_use]
pub fn must_use_result() -> Result<(), ()> {
//~^ ERROR: this function has an empty `#[must_use]` attribute, but returns a type already
//~^ ERROR: this function has a `#[must_use]` attribute with no message, but returns a type already
unimplemented!();
}
#[must_use]
pub fn must_use_tuple() -> (Result<(), ()>, u8) {
//~^ ERROR: this function has an empty `#[must_use]` attribute, but returns a type already
//~^ ERROR: this function has a `#[must_use]` attribute with no message, but returns a type already
unimplemented!();
}
#[must_use]
pub fn must_use_array() -> [Result<(), ()>; 1] {
//~^ ERROR: this function has an empty `#[must_use]` attribute, but returns a type already
//~^ ERROR: this function has a `#[must_use]` attribute with no message, but returns a type already
unimplemented!();
}
@ -32,7 +32,7 @@ async fn async_must_use() -> usize {
#[must_use]
async fn async_must_use_result() -> Result<(), ()> {
//~^ ERROR: this function has an empty `#[must_use]` attribute, but returns a type already
//~^ ERROR: this function has a `#[must_use]` attribute with no message, but returns a type already
Ok(())
}

View File

@ -1,36 +1,36 @@
error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`
error: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
--> tests/ui/double_must_use.rs:5:1
|
LL | pub fn must_use_result() -> Result<(), ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: either add some descriptive text or remove the attribute
= help: either add some descriptive message or remove the attribute
= note: `-D clippy::double-must-use` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::double_must_use)]`
error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`
error: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
--> tests/ui/double_must_use.rs:11:1
|
LL | pub fn must_use_tuple() -> (Result<(), ()>, u8) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: either add some descriptive text or remove the attribute
= help: either add some descriptive message or remove the attribute
error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`
error: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
--> tests/ui/double_must_use.rs:17:1
|
LL | pub fn must_use_array() -> [Result<(), ()>; 1] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: either add some descriptive text or remove the attribute
= help: either add some descriptive message or remove the attribute
error: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]`
error: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
--> tests/ui/double_must_use.rs:34:1
|
LL | async fn async_must_use_result() -> Result<(), ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: either add some descriptive text or remove the attribute
= help: either add some descriptive message or remove the attribute
error: aborting due to 4 previous errors