2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2013-09-30 10:44:58 -05:00
|
|
|
// Issue #7526: lowercase static constants in patterns look like bindings
|
|
|
|
|
|
|
|
// This is similar to compile-fail/match-static-const-lc, except it
|
|
|
|
// shows the expected usual workaround (choosing a different name for
|
|
|
|
// the static definition) and also demonstrates that one can work
|
2013-09-30 18:55:37 -05:00
|
|
|
// around this problem locally by renaming the constant in the `use`
|
2013-09-30 10:44:58 -05:00
|
|
|
// form to an uppercase identifier that placates the lint.
|
|
|
|
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2014-11-05 08:04:26 -06:00
|
|
|
#![deny(non_upper_case_globals)]
|
2013-09-30 10:44:58 -05:00
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
pub const A : isize = 97;
|
2013-09-30 10:44:58 -05:00
|
|
|
|
|
|
|
fn f() {
|
|
|
|
let r = match (0,0) {
|
|
|
|
(0, A) => 0,
|
|
|
|
(x, y) => 1 + x + y,
|
|
|
|
};
|
2015-06-07 13:00:38 -05:00
|
|
|
assert_eq!(r, 1);
|
2013-09-30 19:03:43 -05:00
|
|
|
let r = match (0,97) {
|
|
|
|
(0, A) => 0,
|
|
|
|
(x, y) => 1 + x + y,
|
|
|
|
};
|
2015-06-07 13:00:38 -05:00
|
|
|
assert_eq!(r, 0);
|
2013-09-30 10:44:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
mod m {
|
2014-11-05 08:04:26 -06:00
|
|
|
#[allow(non_upper_case_globals)]
|
2015-03-25 19:06:52 -05:00
|
|
|
pub const aha : isize = 7;
|
2013-09-30 10:44:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn g() {
|
2014-08-12 21:25:05 -05:00
|
|
|
use self::m::aha as AHA;
|
2013-09-30 10:44:58 -05:00
|
|
|
let r = match (0,0) {
|
|
|
|
(0, AHA) => 0,
|
|
|
|
(x, y) => 1 + x + y,
|
|
|
|
};
|
2015-06-07 13:00:38 -05:00
|
|
|
assert_eq!(r, 1);
|
2013-09-30 19:03:43 -05:00
|
|
|
let r = match (0,7) {
|
|
|
|
(0, AHA) => 0,
|
|
|
|
(x, y) => 1 + x + y,
|
|
|
|
};
|
2015-06-07 13:00:38 -05:00
|
|
|
assert_eq!(r, 0);
|
2013-09-30 10:44:58 -05:00
|
|
|
}
|
|
|
|
|
2013-09-30 18:51:21 -05:00
|
|
|
fn h() {
|
|
|
|
let r = match (0,0) {
|
2013-10-01 11:02:11 -05:00
|
|
|
(0, self::m::aha) => 0,
|
2013-09-30 18:51:21 -05:00
|
|
|
(x, y) => 1 + x + y,
|
|
|
|
};
|
2015-06-07 13:00:38 -05:00
|
|
|
assert_eq!(r, 1);
|
2013-09-30 19:03:43 -05:00
|
|
|
let r = match (0,7) {
|
2013-10-01 11:02:11 -05:00
|
|
|
(0, self::m::aha) => 0,
|
2013-09-30 19:03:43 -05:00
|
|
|
(x, y) => 1 + x + y,
|
|
|
|
};
|
2015-06-07 13:00:38 -05:00
|
|
|
assert_eq!(r, 0);
|
2013-09-30 18:51:21 -05:00
|
|
|
}
|
|
|
|
|
2013-10-01 11:02:39 -05:00
|
|
|
pub fn main () {
|
2013-09-30 10:44:58 -05:00
|
|
|
f();
|
|
|
|
g();
|
2013-09-30 18:51:21 -05:00
|
|
|
h();
|
2013-09-30 10:44:58 -05:00
|
|
|
}
|