]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/match_wild_err_arm.rs
7bdd75d7f46396480596c50283877c19653b1cd3
1 #![feature(exclusive_range_pattern)]
2 #![allow(clippy::match_same_arms, dead_code)]
3 #![warn(clippy::match_wild_err_arm)]
11 // Don't trigger in const contexts. Const unwrap is not yet stable
12 const X
: () = match Ok
::<_
, Error
>(()) {
18 fn match_wild_err_arm() {
19 let x
: Result
<i32, &str> = Ok(3);
22 Ok(3) => println
!("ok"),
23 Ok(_
) => println
!("ok"),
24 Err(_
) => panic
!("err"),
25 //~^ ERROR: `Err(_)` matches all errors
26 //~| NOTE: match each error separately or use the error output, or use `.expect(ms
30 Ok(3) => println
!("ok"),
31 Ok(_
) => println
!("ok"),
33 //~^ ERROR: `Err(_)` matches all errors
34 //~| NOTE: match each error separately or use the error output, or use `.expect(ms
38 Ok(3) => println
!("ok"),
39 Ok(_
) => println
!("ok"),
41 //~^ ERROR: `Err(_)` matches all errors
42 //~| NOTE: match each error separately or use the error output, or use `.expect(ms
48 Ok(3) => println
!("ok"),
49 Ok(_
) => println
!("ok"),
51 //~^ ERROR: `Err(_e)` matches all errors
52 //~| NOTE: match each error separately or use the error output, or use `.expect(ms
55 // Allowed when used in `panic!`.
57 Ok(3) => println
!("ok"),
58 Ok(_
) => println
!("ok"),
59 Err(_e
) => panic
!("{}", _e
),
62 // Allowed when not with `panic!` block.
64 Ok(3) => println
!("ok"),
65 Ok(_
) => println
!("ok"),
66 Err(_
) => println
!("err"),
69 // Allowed when used with `unreachable!`.
71 Ok(3) => println
!("ok"),
72 Ok(_
) => println
!("ok"),
73 Err(_
) => unreachable
!(),
76 // Allowed when used with `unreachable!`.
78 Ok(3) => println
!("ok"),
79 Ok(_
) => println
!("ok"),