]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/lint-lowercase-static-const-pattern-rename.rs
Auto merge of #106884 - clubby789:fieldless-enum-debug, r=michaelwoerister
[rust.git] / tests / ui / lint / lint-lowercase-static-const-pattern-rename.rs
1 // check-pass
2 // Issue #7526: lowercase static constants in patterns look like bindings
3
4 // This is similar to lint-lowercase-static-const-pattern.rs, except it
5 // shows the expected usual workaround (choosing a different name for
6 // the static definition) and also demonstrates that one can work
7 // around this problem locally by renaming the constant in the `use`
8 // form to an uppercase identifier that placates the lint.
9
10 #![deny(non_upper_case_globals)]
11
12 pub const A : isize = 97;
13
14 fn f() {
15     let r = match (0,0) {
16         (0, A) => 0,
17         (x, y) => 1 + x + y,
18     };
19     assert_eq!(r, 1);
20     let r = match (0,97) {
21         (0, A) => 0,
22         (x, y) => 1 + x + y,
23     };
24     assert_eq!(r, 0);
25 }
26
27 mod m {
28     #[allow(non_upper_case_globals)]
29     pub const aha : isize = 7;
30 }
31
32 fn g() {
33     use self::m::aha as AHA;
34     let r = match (0,0) {
35         (0, AHA) => 0,
36         (x, y)   => 1 + x + y,
37     };
38     assert_eq!(r, 1);
39     let r = match (0,7) {
40         (0, AHA) => 0,
41         (x, y)   => 1 + x + y,
42     };
43     assert_eq!(r, 0);
44 }
45
46 fn h() {
47     let r = match (0,0) {
48         (0, self::m::aha) => 0,
49         (x, y)      => 1 + x + y,
50     };
51     assert_eq!(r, 1);
52     let r = match (0,7) {
53         (0, self::m::aha) => 0,
54         (x, y)      => 1 + x + y,
55     };
56     assert_eq!(r, 0);
57 }
58
59 pub fn main () {
60     f();
61     g();
62     h();
63 }