]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/lint-lowercase-static-const-pattern.rs
Rollup merge of #87180 - notriddle:notriddle/sidebar-keyboard-mobile, r=GuillaumeGomez
[rust.git] / src / test / ui / lint / lint-lowercase-static-const-pattern.rs
1 // Issue #7526: lowercase static constants in patterns look like bindings
2
3 #![allow(dead_code)]
4 #![deny(non_upper_case_globals)]
5
6 #[allow(non_upper_case_globals)]
7 pub const a : isize = 97;
8
9 fn f() {
10     let r = match (0,0) {
11         (0, a) => 0,
12         //~^ ERROR constant in pattern `a` should have an upper case name
13         (x, y) => 1 + x + y,
14     };
15     assert_eq!(r, 1);
16 }
17
18 mod m {
19     #[allow(non_upper_case_globals)]
20     pub const aha : isize = 7;
21 }
22
23 fn g() {
24     use self::m::aha;
25     let r = match (0,0) {
26         (0, aha) => 0,
27         //~^ ERROR constant in pattern `aha` should have an upper case name
28         (x, y)   => 1 + x + y,
29     };
30     assert_eq!(r, 1);
31 }
32
33 mod n {
34     pub const OKAY : isize = 8;
35 }
36
37 fn h() {
38     use self::n::OKAY as not_okay;
39     let r = match (0,0) {
40         (0, not_okay) => 0,
41 //~^ ERROR constant in pattern `not_okay` should have an upper case name
42         (x, y)   => 1 + x + y,
43     };
44     assert_eq!(r, 1);
45 }
46
47 fn main () {
48     f();
49     g();
50     h();
51 }