1
1
error: this function's return value is unnecessarily wrapped by `Option`
2
2
--> tests/ui/unnecessary_wraps.rs:9:1
3
3
|
4
- LL | / fn func1(a: bool, b: bool) -> Option<i32> {
5
- LL | |
6
- LL | |
7
- LL | | if a && b {
8
- ... |
9
- LL | | }
10
- | |_^
4
+ LL | fn func1(a: bool, b: bool) -> Option<i32> {
5
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11
6
|
12
7
= note: `-D clippy::unnecessary-wraps` implied by `-D warnings`
13
8
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_wraps)]`
@@ -16,7 +11,7 @@ help: remove `Option` from the return type...
16
11
LL - fn func1(a: bool, b: bool) -> Option<i32> {
17
12
LL + fn func1(a: bool, b: bool) -> i32 {
18
13
|
19
- help: ...and then change returning expressions
14
+ help: ...and then remove the surrounding `Some()` from returning expressions
20
15
|
21
16
LL ~ return 42;
22
17
LL | }
@@ -30,21 +25,15 @@ LL ~ return 1337;
30
25
error: this function's return value is unnecessarily wrapped by `Option`
31
26
--> tests/ui/unnecessary_wraps.rs:24:1
32
27
|
33
- LL | / fn func2(a: bool, b: bool) -> Option<i32> {
34
- LL | |
35
- LL | |
36
- LL | | if a && b {
37
- ... |
38
- LL | | if a { Some(20) } else { Some(30) }
39
- LL | | }
40
- | |_^
28
+ LL | fn func2(a: bool, b: bool) -> Option<i32> {
29
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41
30
|
42
31
help: remove `Option` from the return type...
43
32
|
44
33
LL - fn func2(a: bool, b: bool) -> Option<i32> {
45
34
LL + fn func2(a: bool, b: bool) -> i32 {
46
35
|
47
- help: ...and then change returning expressions
36
+ help: ...and then remove the surrounding `Some()` from returning expressions
48
37
|
49
38
LL ~ return 10;
50
39
LL | }
@@ -54,19 +43,15 @@ LL ~ if a { 20 } else { 30 }
54
43
error: this function's return value is unnecessarily wrapped by `Option`
55
44
--> tests/ui/unnecessary_wraps.rs:44:1
56
45
|
57
- LL | / fn func5() -> Option<i32> {
58
- LL | |
59
- LL | |
60
- LL | | Some(1)
61
- LL | | }
62
- | |_^
46
+ LL | fn func5() -> Option<i32> {
47
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
63
48
|
64
49
help: remove `Option` from the return type...
65
50
|
66
51
LL - fn func5() -> Option<i32> {
67
52
LL + fn func5() -> i32 {
68
53
|
69
- help: ...and then change returning expressions
54
+ help: ...and then remove the surrounding `Some()` from returning expressions
70
55
|
71
56
LL - Some(1)
72
57
LL + 1
@@ -75,19 +60,15 @@ LL + 1
75
60
error: this function's return value is unnecessarily wrapped by `Result`
76
61
--> tests/ui/unnecessary_wraps.rs:56:1
77
62
|
78
- LL | / fn func7() -> Result<i32, ()> {
79
- LL | |
80
- LL | |
81
- LL | | Ok(1)
82
- LL | | }
83
- | |_^
63
+ LL | fn func7() -> Result<i32, ()> {
64
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
84
65
|
85
66
help: remove `Result` from the return type...
86
67
|
87
68
LL - fn func7() -> Result<i32, ()> {
88
69
LL + fn func7() -> i32 {
89
70
|
90
- help: ...and then change returning expressions
71
+ help: ...and then remove the surrounding `Ok()` from returning expressions
91
72
|
92
73
LL - Ok(1)
93
74
LL + 1
@@ -96,19 +77,15 @@ LL + 1
96
77
error: this function's return value is unnecessarily wrapped by `Option`
97
78
--> tests/ui/unnecessary_wraps.rs:86:5
98
79
|
99
- LL | / fn func12() -> Option<i32> {
100
- LL | |
101
- LL | |
102
- LL | | Some(1)
103
- LL | | }
104
- | |_____^
80
+ LL | fn func12() -> Option<i32> {
81
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
105
82
|
106
83
help: remove `Option` from the return type...
107
84
|
108
85
LL - fn func12() -> Option<i32> {
109
86
LL + fn func12() -> i32 {
110
87
|
111
- help: ...and then change returning expressions
88
+ help: ...and then remove the surrounding `Some()` from returning expressions
112
89
|
113
90
LL - Some(1)
114
91
LL + 1
@@ -117,13 +94,8 @@ LL + 1
117
94
error: this function's return value is unnecessary
118
95
--> tests/ui/unnecessary_wraps.rs:115:1
119
96
|
120
- LL | / fn issue_6640_1(a: bool, b: bool) -> Option<()> {
121
- LL | |
122
- LL | |
123
- LL | | if a && b {
124
- ... |
125
- LL | | }
126
- | |_^
97
+ LL | fn issue_6640_1(a: bool, b: bool) -> Option<()> {
98
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127
99
|
128
100
help: remove the return type...
129
101
|
@@ -144,13 +116,8 @@ LL ~ return ;
144
116
error: this function's return value is unnecessary
145
117
--> tests/ui/unnecessary_wraps.rs:130:1
146
118
|
147
- LL | / fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> {
148
- LL | |
149
- LL | |
150
- LL | | if a && b {
151
- ... |
152
- LL | | }
153
- | |_^
119
+ LL | fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> {
120
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
154
121
|
155
122
help: remove the return type...
156
123
|
0 commit comments