]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui-toml/min_rust_version/min_rust_version.rs
Rollup merge of #89929 - yuvaldolev:handle-submodule-checkout-more-gracefully, r...
[rust.git] / src / tools / clippy / tests / ui-toml / min_rust_version / min_rust_version.rs
1 #![allow(clippy::redundant_clone)]
2 #![warn(clippy::manual_non_exhaustive)]
3
4 use std::ops::Deref;
5
6 mod enums {
7     enum E {
8         A,
9         B,
10         #[doc(hidden)]
11         _C,
12     }
13
14     // user forgot to remove the marker
15     #[non_exhaustive]
16     enum Ep {
17         A,
18         B,
19         #[doc(hidden)]
20         _C,
21     }
22 }
23
24 fn option_as_ref_deref() {
25     let mut opt = Some(String::from("123"));
26
27     let _ = opt.as_ref().map(String::as_str);
28     let _ = opt.as_ref().map(|x| x.as_str());
29     let _ = opt.as_mut().map(String::as_mut_str);
30     let _ = opt.as_mut().map(|x| x.as_mut_str());
31 }
32
33 fn match_like_matches() {
34     let _y = match Some(5) {
35         Some(0) => true,
36         _ => false,
37     };
38 }
39
40 fn match_same_arms() {
41     match (1, 2, 3) {
42         (1, .., 3) => 42,
43         (.., 3) => 42, //~ ERROR match arms have same body
44         _ => 0,
45     };
46 }
47
48 fn match_same_arms2() {
49     let _ = match Some(42) {
50         Some(_) => 24,
51         None => 24, //~ ERROR match arms have same body
52     };
53 }
54
55 fn manual_strip_msrv() {
56     let s = "hello, world!";
57     if s.starts_with("hello, ") {
58         assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
59     }
60 }
61
62 fn main() {
63     option_as_ref_deref();
64     match_like_matches();
65     match_same_arms();
66     match_same_arms2();
67     manual_strip_msrv();
68 }