Skip to content

Commit e0e51e4

Browse files
committed
Fixed test
1 parent bfbc083 commit e0e51e4

File tree

3 files changed

+116
-8
lines changed

3 files changed

+116
-8
lines changed

clippy_lints/src/unnecessary_wraps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
140140
UNNECESSARY_WRAPS,
141141
fn_decl.output.span(),
142142
"unneeded wrapped unit return type",
143-
format!("remove the `-> {}<()>`", return_type_label).as_str(),
143+
format!("remove the `-> {}<[...]>`", return_type_label).as_str(),
144144
String::new(),
145145
Applicability::MaybeIncorrect,
146146
);

tests/ui/unnecessary_wraps.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> {
135135
return Ok(());
136136
}
137137
if a {
138-
Ok(());
139138
Ok(())
140139
} else {
141140
return Ok(());

tests/ui/unnecessary_wraps.stderr

Lines changed: 115 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,118 @@
1-
error[E0282]: type annotations needed
2-
--> $DIR/unnecessary_wraps.rs:138:9
1+
error: this function's return value is unnecessarily wrapped by `Option`
2+
--> $DIR/unnecessary_wraps.rs:8:1
33
|
4-
LL | Ok(());
5-
| ^^ cannot infer type for type parameter `E` declared on the enum `Result`
4+
LL | / fn func1(a: bool, b: bool) -> Option<i32> {
5+
LL | | if a && b {
6+
LL | | return Some(42);
7+
LL | | }
8+
... |
9+
LL | | }
10+
LL | | }
11+
| |_^
12+
|
13+
= note: `-D clippy::unnecessary-wraps` implied by `-D warnings`
14+
help: remove `Option` from the return type...
15+
|
16+
LL | fn func1(a: bool, b: bool) -> i32 {
17+
| ^^^
18+
help: ...and change the returning expressions
19+
|
20+
LL | return 42;
21+
LL | }
22+
LL | if a {
23+
LL | Some(-1);
24+
LL | 2
25+
LL | } else {
26+
...
27+
28+
error: this function's return value is unnecessarily wrapped by `Option`
29+
--> $DIR/unnecessary_wraps.rs:21:1
30+
|
31+
LL | / fn func2(a: bool, b: bool) -> Option<i32> {
32+
LL | | if a && b {
33+
LL | | return Some(10);
34+
LL | | }
35+
... |
36+
LL | | }
37+
LL | | }
38+
| |_^
39+
|
40+
help: remove `Option` from the return type...
41+
|
42+
LL | fn func2(a: bool, b: bool) -> i32 {
43+
| ^^^
44+
help: ...and change the returning expressions
45+
|
46+
LL | return 10;
47+
LL | }
48+
LL | if a {
49+
LL | 20
50+
LL | } else {
51+
LL | 30
52+
|
53+
54+
error: this function's return value is unnecessarily wrapped by `Option`
55+
--> $DIR/unnecessary_wraps.rs:51:1
56+
|
57+
LL | / fn func5() -> Option<i32> {
58+
LL | | Some(1)
59+
LL | | }
60+
| |_^
61+
|
62+
help: remove `Option` from the return type...
63+
|
64+
LL | fn func5() -> i32 {
65+
| ^^^
66+
help: ...and change the returning expressions
67+
|
68+
LL | 1
69+
|
70+
71+
error: this function's return value is unnecessarily wrapped by `Result`
72+
--> $DIR/unnecessary_wraps.rs:61:1
73+
|
74+
LL | / fn func7() -> Result<i32, ()> {
75+
LL | | Ok(1)
76+
LL | | }
77+
| |_^
78+
|
79+
help: remove `Result` from the return type...
80+
|
81+
LL | fn func7() -> i32 {
82+
| ^^^
83+
help: ...and change the returning expressions
84+
|
85+
LL | 1
86+
|
87+
88+
error: this function's return value is unnecessarily wrapped by `Option`
89+
--> $DIR/unnecessary_wraps.rs:93:5
90+
|
91+
LL | / fn func12() -> Option<i32> {
92+
LL | | Some(1)
93+
LL | | }
94+
| |_____^
95+
|
96+
help: remove `Option` from the return type...
97+
|
98+
LL | fn func12() -> i32 {
99+
| ^^^
100+
help: ...and change the returning expressions
101+
|
102+
LL | 1
103+
|
104+
105+
error: unneeded wrapped unit return type
106+
--> $DIR/unnecessary_wraps.rs:120:38
107+
|
108+
LL | fn issue_6640_1(a: bool, b: bool) -> Option<()> {
109+
| ^^^^^^^^^^ help: remove the `-> Option<[...]>`
110+
111+
error: unneeded wrapped unit return type
112+
--> $DIR/unnecessary_wraps.rs:133:38
113+
|
114+
LL | fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> {
115+
| ^^^^^^^^^^^^^^^ help: remove the `-> Result<[...]>`
6116

7-
error: aborting due to previous error
117+
error: aborting due to 7 previous errors
8118

9-
For more information about this error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)