Skip to content

Commit 3991dd1

Browse files
committed
fix reviewer comments: tests results
1 parent 342ce3d commit 3991dd1

3 files changed

+57
-37
lines changed

tests/ui/redundant_pattern_matching_result.fixed

+17-7
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,26 @@ const fn issue6067() {
110110
}
111111

112112
fn issue10726() {
113-
Ok::<i32, i32>(42).is_ok();
113+
// This is optional, but it makes the examples easier
114+
let x: Result<i32, i32> = Ok(42);
114115

115-
Ok::<i32, i32>(42).is_err();
116+
x.is_ok();
116117

117-
Err::<i32, i32>(42).is_ok();
118+
x.is_err();
118119

119-
Err::<i32, i32>(42).is_err();
120+
x.is_err();
121+
122+
x.is_ok();
123+
124+
// Don't lint
125+
match x {
126+
Err(16) => false,
127+
_ => true,
128+
};
120129

121-
match Ok::<i32, i32>(42) {
122-
Ok(21) => true,
123-
_ => false,
130+
// Don't lint
131+
match x {
132+
Ok(16) => false,
133+
_ => true,
124134
};
125135
}

tests/ui/redundant_pattern_matching_result.rs

+21-11
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,38 @@ const fn issue6067() {
128128
}
129129

130130
fn issue10726() {
131-
match Ok::<i32, i32>(42) {
131+
// This is optional, but it makes the examples easier
132+
let x: Result<i32, i32> = Ok(42);
133+
134+
match x {
132135
Ok(_) => true,
133136
_ => false,
134137
};
135138

136-
match Ok::<i32, i32>(42) {
139+
match x {
140+
Ok(_) => false,
141+
_ => true,
142+
};
143+
144+
match x {
137145
Err(_) => true,
138146
_ => false,
139147
};
140148

141-
match Err::<i32, i32>(42) {
142-
Ok(_) => true,
143-
_ => false,
149+
match x {
150+
Err(_) => false,
151+
_ => true,
144152
};
145153

146-
match Err::<i32, i32>(42) {
147-
Err(_) => true,
148-
_ => false,
154+
// Don't lint
155+
match x {
156+
Err(16) => false,
157+
_ => true,
149158
};
150159

151-
match Ok::<i32, i32>(42) {
152-
Ok(21) => true,
153-
_ => false,
160+
// Don't lint
161+
match x {
162+
Ok(16) => false,
163+
_ => true,
154164
};
155165
}

tests/ui/redundant_pattern_matching_result.stderr

+19-19
Original file line numberDiff line numberDiff line change
@@ -151,40 +151,40 @@ LL | | };
151151
| |_____^ help: try this: `Err::<i32, i32>(42).is_err()`
152152

153153
error: redundant pattern matching, consider using `is_ok()`
154-
--> $DIR/redundant_pattern_matching_result.rs:131:5
154+
--> $DIR/redundant_pattern_matching_result.rs:134:5
155155
|
156-
LL | / match Ok::<i32, i32>(42) {
156+
LL | / match x {
157157
LL | | Ok(_) => true,
158158
LL | | _ => false,
159159
LL | | };
160-
| |_____^ help: try this: `Ok::<i32, i32>(42).is_ok()`
160+
| |_____^ help: try this: `x.is_ok()`
161161

162162
error: redundant pattern matching, consider using `is_err()`
163-
--> $DIR/redundant_pattern_matching_result.rs:136:5
163+
--> $DIR/redundant_pattern_matching_result.rs:139:5
164164
|
165-
LL | / match Ok::<i32, i32>(42) {
166-
LL | | Err(_) => true,
167-
LL | | _ => false,
165+
LL | / match x {
166+
LL | | Ok(_) => false,
167+
LL | | _ => true,
168168
LL | | };
169-
| |_____^ help: try this: `Ok::<i32, i32>(42).is_err()`
169+
| |_____^ help: try this: `x.is_err()`
170170

171-
error: redundant pattern matching, consider using `is_ok()`
172-
--> $DIR/redundant_pattern_matching_result.rs:141:5
171+
error: redundant pattern matching, consider using `is_err()`
172+
--> $DIR/redundant_pattern_matching_result.rs:144:5
173173
|
174-
LL | / match Err::<i32, i32>(42) {
175-
LL | | Ok(_) => true,
174+
LL | / match x {
175+
LL | | Err(_) => true,
176176
LL | | _ => false,
177177
LL | | };
178-
| |_____^ help: try this: `Err::<i32, i32>(42).is_ok()`
178+
| |_____^ help: try this: `x.is_err()`
179179

180-
error: redundant pattern matching, consider using `is_err()`
181-
--> $DIR/redundant_pattern_matching_result.rs:146:5
180+
error: redundant pattern matching, consider using `is_ok()`
181+
--> $DIR/redundant_pattern_matching_result.rs:149:5
182182
|
183-
LL | / match Err::<i32, i32>(42) {
184-
LL | | Err(_) => true,
185-
LL | | _ => false,
183+
LL | / match x {
184+
LL | | Err(_) => false,
185+
LL | | _ => true,
186186
LL | | };
187-
| |_____^ help: try this: `Err::<i32, i32>(42).is_err()`
187+
| |_____^ help: try this: `x.is_ok()`
188188

189189
error: aborting due to 26 previous errors
190190

0 commit comments

Comments
 (0)