fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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