Skip to content

Commit 339caa1

Browse files
committed
unused_must_use: Rename test functions to reflect what they test
This makes it easier to review without cross-referencing each test function with its invocation.
1 parent 39f59bf commit 339caa1

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

tests/ui/lint/unused/must_use-result-unit-uninhabited.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
use core::ops::{ControlFlow, ControlFlow::Continue};
88
use dep::{MyUninhabited, MyUninhabitedNonexhaustive};
99

10-
fn f1() -> Result<(), ()> {
10+
fn result_unit_unit() -> Result<(), ()> {
1111
Ok(())
1212
}
1313

14-
fn f2() -> Result<(), core::convert::Infallible> {
14+
fn result_unit_infallible() -> Result<(), core::convert::Infallible> {
1515
Ok(())
1616
}
1717

18-
fn f3() -> Result<(), !> {
18+
fn result_unit_never() -> Result<(), !> {
1919
Ok(())
2020
}
2121

22-
fn f4() -> Result<(), MyUninhabited> {
22+
fn result_unit_myuninhabited() -> Result<(), MyUninhabited> {
2323
Ok(())
2424
}
2525

26-
fn f5() -> Result<(), MyUninhabitedNonexhaustive> {
26+
fn result_unit_myuninhabited_nonexhaustive() -> Result<(), MyUninhabitedNonexhaustive> {
2727
Ok(())
2828
}
2929

@@ -41,53 +41,53 @@ impl AssocType for S2 {
4141
type Error = ();
4242
}
4343

44-
fn f6<AT: AssocType>(_: AT) -> Result<(), AT::Error> {
44+
fn result_unit_assoctype<AT: AssocType>(_: AT) -> Result<(), AT::Error> {
4545
Ok(())
4646
}
4747

4848
trait UsesAssocType {
4949
type Error;
50-
fn method(&self) -> Result<(), Self::Error>;
50+
fn method_use_assoc_type(&self) -> Result<(), Self::Error>;
5151
}
5252

5353
impl UsesAssocType for S1 {
5454
type Error = !;
55-
fn method(&self) -> Result<(), Self::Error> {
55+
fn method_use_assoc_type(&self) -> Result<(), Self::Error> {
5656
Ok(())
5757
}
5858
}
5959

6060
impl UsesAssocType for S2 {
6161
type Error = ();
62-
fn method(&self) -> Result<(), Self::Error> {
62+
fn method_use_assoc_type(&self) -> Result<(), Self::Error> {
6363
Err(())
6464
}
6565
}
6666

67-
fn c1() -> ControlFlow<()> {
67+
fn controlflow_unit() -> ControlFlow<()> {
6868
Continue(())
6969
}
7070

71-
fn c2() -> ControlFlow<core::convert::Infallible, ()> {
71+
fn controlflow_infallible_unit() -> ControlFlow<core::convert::Infallible, ()> {
7272
Continue(())
7373
}
7474

75-
fn c3() -> ControlFlow<!> {
75+
fn controlflow_never() -> ControlFlow<!> {
7676
Continue(())
7777
}
7878

7979
fn main() {
80-
f1(); //~ ERROR: unused `Result` that must be used
81-
f2();
82-
f3();
83-
f4();
84-
f5(); //~ ERROR: unused `Result` that must be used
85-
f6(S1);
86-
f6(S2); //~ ERROR: unused `Result` that must be used
87-
S1.method();
88-
S2.method(); //~ ERROR: unused `Result` that must be used
89-
90-
c1(); //~ ERROR: unused `ControlFlow` that must be used
91-
c2();
92-
c3();
80+
result_unit_unit(); //~ ERROR: unused `Result` that must be used
81+
result_unit_infallible();
82+
result_unit_never();
83+
result_unit_myuninhabited();
84+
result_unit_myuninhabited_nonexhaustive(); //~ ERROR: unused `Result` that must be used
85+
result_unit_assoctype(S1);
86+
result_unit_assoctype(S2); //~ ERROR: unused `Result` that must be used
87+
S1.method_use_assoc_type();
88+
S2.method_use_assoc_type(); //~ ERROR: unused `Result` that must be used
89+
90+
controlflow_unit(); //~ ERROR: unused `ControlFlow` that must be used
91+
controlflow_infallible_unit();
92+
controlflow_never();
9393
}

tests/ui/lint/unused/must_use-result-unit-uninhabited.stderr

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: unused `Result` that must be used
22
--> $DIR/must_use-result-unit-uninhabited.rs:80:5
33
|
4-
LL | f1();
5-
| ^^^^
4+
LL | result_unit_unit();
5+
| ^^^^^^^^^^^^^^^^^^
66
|
77
= note: this `Result` may be an `Err` variant, which should be handled
88
note: the lint level is defined here
@@ -12,54 +12,54 @@ LL | #![deny(unused_must_use)]
1212
| ^^^^^^^^^^^^^^^
1313
help: use `let _ = ...` to ignore the resulting value
1414
|
15-
LL | let _ = f1();
15+
LL | let _ = result_unit_unit();
1616
| +++++++
1717

1818
error: unused `Result` that must be used
1919
--> $DIR/must_use-result-unit-uninhabited.rs:84:5
2020
|
21-
LL | f5();
22-
| ^^^^
21+
LL | result_unit_myuninhabited_nonexhaustive();
22+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323
|
2424
= note: this `Result` may be an `Err` variant, which should be handled
2525
help: use `let _ = ...` to ignore the resulting value
2626
|
27-
LL | let _ = f5();
27+
LL | let _ = result_unit_myuninhabited_nonexhaustive();
2828
| +++++++
2929

3030
error: unused `Result` that must be used
3131
--> $DIR/must_use-result-unit-uninhabited.rs:86:5
3232
|
33-
LL | f6(S2);
34-
| ^^^^^^
33+
LL | result_unit_assoctype(S2);
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
3535
|
3636
= note: this `Result` may be an `Err` variant, which should be handled
3737
help: use `let _ = ...` to ignore the resulting value
3838
|
39-
LL | let _ = f6(S2);
39+
LL | let _ = result_unit_assoctype(S2);
4040
| +++++++
4141

4242
error: unused `Result` that must be used
4343
--> $DIR/must_use-result-unit-uninhabited.rs:88:5
4444
|
45-
LL | S2.method();
46-
| ^^^^^^^^^^^
45+
LL | S2.method_use_assoc_type();
46+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
4747
|
4848
= note: this `Result` may be an `Err` variant, which should be handled
4949
help: use `let _ = ...` to ignore the resulting value
5050
|
51-
LL | let _ = S2.method();
51+
LL | let _ = S2.method_use_assoc_type();
5252
| +++++++
5353

5454
error: unused `ControlFlow` that must be used
5555
--> $DIR/must_use-result-unit-uninhabited.rs:90:5
5656
|
57-
LL | c1();
58-
| ^^^^
57+
LL | controlflow_unit();
58+
| ^^^^^^^^^^^^^^^^^^
5959
|
6060
help: use `let _ = ...` to ignore the resulting value
6161
|
62-
LL | let _ = c1();
62+
LL | let _ = controlflow_unit();
6363
| +++++++
6464

6565
error: aborting due to 5 previous errors

0 commit comments

Comments
 (0)