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