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