]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/redundant_pattern_matching_const_result.fixed
use iter:: before free functions
[rust.git] / src / tools / clippy / tests / ui / redundant_pattern_matching_const_result.fixed
1 // run-rustfix
2
3 #![feature(const_result)]
4 #![warn(clippy::redundant_pattern_matching)]
5 #![allow(clippy::match_like_matches_macro, unused)]
6
7 // Test that results are linted with the feature enabled.
8
9 const fn issue_5697() {
10     if Ok::<i32, i32>(42).is_ok() {}
11
12     if Err::<i32, i32>(42).is_err() {}
13
14     while Ok::<i32, i32>(10).is_ok() {}
15
16     while Ok::<i32, i32>(10).is_err() {}
17
18     Ok::<i32, i32>(42).is_ok();
19
20     Err::<i32, i32>(42).is_err();
21
22     // These should not be linted until `const_option` is implemented.
23     // See https://github.com/rust-lang/rust/issues/67441
24
25     if let Some(_) = Some(42) {}
26
27     if let None = None::<()> {}
28
29     while let Some(_) = Some(42) {}
30
31     while let None = None::<()> {}
32
33     match Some(42) {
34         Some(_) => true,
35         None => false,
36     };
37
38     match None::<()> {
39         Some(_) => false,
40         None => true,
41     };
42 }
43
44 fn main() {}