Skip to content

Commit 1858469

Browse files
committed
Add failing test
1 parent e722b13 commit 1858469

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

tests/ui/question_mark.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ fn some_func(a: Option<u32>) -> Option<u32> {
1515
a
1616
}
1717

18+
fn some_other_func(a: Option<u32>) -> Option<u32> {
19+
if a.is_none() {
20+
return None;
21+
} else {
22+
return Some(0);
23+
}
24+
unreachable!()
25+
}
26+
1827
pub enum SeemsOption<T> {
1928
Some(T),
2029
None,

tests/ui/question_mark.stderr

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,54 @@ error: this block may be rewritten with the `?` operator
99
= note: `-D clippy::question-mark` implied by `-D warnings`
1010

1111
error: this block may be rewritten with the `?` operator
12-
--> $DIR/question_mark.rs:47:9
12+
--> $DIR/question_mark.rs:56:9
1313
|
14-
47 | / if (self.opt).is_none() {
15-
48 | | return None;
16-
49 | | }
14+
56 | / if (self.opt).is_none() {
15+
57 | | return None;
16+
58 | | }
1717
| |_________^ help: replace_it_with: `(self.opt)?;`
1818

1919
error: this block may be rewritten with the `?` operator
20-
--> $DIR/question_mark.rs:51:9
20+
--> $DIR/question_mark.rs:60:9
2121
|
22-
51 | / if self.opt.is_none() {
23-
52 | | return None
24-
53 | | }
22+
60 | / if self.opt.is_none() {
23+
61 | | return None
24+
62 | | }
2525
| |_________^ help: replace_it_with: `self.opt?;`
2626

2727
error: this block may be rewritten with the `?` operator
28-
--> $DIR/question_mark.rs:55:17
28+
--> $DIR/question_mark.rs:64:17
2929
|
30-
55 | let _ = if self.opt.is_none() {
30+
64 | let _ = if self.opt.is_none() {
3131
| _________________^
32-
56 | | return None;
33-
57 | | } else {
34-
58 | | self.opt
35-
59 | | };
32+
65 | | return None;
33+
66 | | } else {
34+
67 | | self.opt
35+
68 | | };
3636
| |_________^ help: replace_it_with: `Some(self.opt?)`
3737

3838
error: this block may be rewritten with the `?` operator
39-
--> $DIR/question_mark.rs:72:9
39+
--> $DIR/question_mark.rs:81:9
4040
|
41-
72 | / if self.opt.is_none() {
42-
73 | | return None;
43-
74 | | }
41+
81 | / if self.opt.is_none() {
42+
82 | | return None;
43+
83 | | }
4444
| |_________^ help: replace_it_with: `self.opt.as_ref()?;`
4545

4646
error: this block may be rewritten with the `?` operator
47-
--> $DIR/question_mark.rs:80:9
47+
--> $DIR/question_mark.rs:89:9
4848
|
49-
80 | / if self.opt.is_none() {
50-
81 | | return None;
51-
82 | | }
49+
89 | / if self.opt.is_none() {
50+
90 | | return None;
51+
91 | | }
5252
| |_________^ help: replace_it_with: `self.opt.as_ref()?;`
5353

5454
error: this block may be rewritten with the `?` operator
55-
--> $DIR/question_mark.rs:88:9
55+
--> $DIR/question_mark.rs:97:9
5656
|
57-
88 | / if self.opt.is_none() {
58-
89 | | return None;
59-
90 | | }
57+
97 | / if self.opt.is_none() {
58+
98 | | return None;
59+
99 | | }
6060
| |_________^ help: replace_it_with: `self.opt.as_ref()?;`
6161

6262
error: aborting due to 7 previous errors

0 commit comments

Comments
 (0)