Skip to content

Commit 3c14075

Browse files
committed
manual_filter: add a related test
The related issue is #9766 where the `manual_filter` lint would remove side effects
1 parent 5b3a666 commit 3c14075

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/ui/manual_filter.fixed

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,20 @@ fn main() {
139139
} else {
140140
None
141141
};
142+
143+
let allowed_integers = vec![3, 4, 5, 6];
144+
// Don't lint, since there's a side effect in the else branch
145+
match Some(21) {
146+
Some(x) => {
147+
if allowed_integers.contains(&x) {
148+
Some(x)
149+
} else {
150+
println!("Invalid integer: {x:?}");
151+
None
152+
}
153+
},
154+
None => None,
155+
};
142156
}
143157

144158
fn maybe_some() -> Option<u32> {

tests/ui/manual_filter.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,20 @@ fn main() {
263263
} else {
264264
None
265265
};
266+
267+
let allowed_integers = vec![3, 4, 5, 6];
268+
// Don't lint, since there's a side effect in the else branch
269+
match Some(21) {
270+
Some(x) => {
271+
if allowed_integers.contains(&x) {
272+
Some(x)
273+
} else {
274+
println!("Invalid integer: {x:?}");
275+
None
276+
}
277+
},
278+
None => None,
279+
};
266280
}
267281

268282
fn maybe_some() -> Option<u32> {

0 commit comments

Comments
 (0)