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