]> git.lizzy.rs Git - rust.git/blob - tests/ui-toml/expect_used/expect_used.rs
[`unwrap_used`], [`expect_used`] do not lint in `test` cfg
[rust.git] / tests / ui-toml / expect_used / expect_used.rs
1 // compile-flags: --test
2 #![warn(clippy::expect_used)]
3
4 fn expect_option() {
5     let opt = Some(0);
6     let _ = opt.expect("");
7 }
8
9 fn expect_result() {
10     let res: Result<u8, ()> = Ok(0);
11     let _ = res.expect("");
12 }
13
14 fn main() {
15     expect_option();
16     expect_result();
17 }
18
19 #[cfg(test)]
20 mod issue9612 {
21     // should not lint in `#[cfg(test)]` modules
22     #[test]
23     fn test_fn() {
24         let _a: u8 = 2.try_into().unwrap();
25         let _a: u8 = 3.try_into().expect("");
26
27         util();
28     }
29
30     fn util() {
31         let _a: u8 = 4.try_into().unwrap();
32         let _a: u8 = 5.try_into().expect("");
33     }
34 }