Skip to content

Commit 70d8b8d

Browse files
committed
auto merge of #17948 : jakub-/rust/issue-17933, r=alexcrichton
Fixes #17933.
2 parents a6e0c76 + fdc1eea commit 70d8b8d

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/librustc/middle/resolve.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5073,10 +5073,15 @@ impl<'a> Resolver<'a> {
50735073
Some(def @ (DefFn(..), _)) |
50745074
Some(def @ (DefVariant(..), _)) |
50755075
Some(def @ (DefStruct(..), _)) |
5076-
Some(def @ (DefConst(..), _)) |
5077-
Some(def @ (DefStatic(..), _)) => {
5076+
Some(def @ (DefConst(..), _)) => {
50785077
self.record_def(pattern.id, def);
50795078
}
5079+
Some((DefStatic(..), _)) => {
5080+
self.resolve_error(path.span,
5081+
"static variables cannot be \
5082+
referenced in a pattern, \
5083+
use a `const` instead");
5084+
}
50805085
Some(_) => {
50815086
self.resolve_error(path.span,
50825087
format!("`{}` is not an enum variant, struct or const",

src/test/compile-fail/issue-17933.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub static X: uint = 1u;
12+
13+
fn main() {
14+
match 1u {
15+
self::X => { },
16+
//~^ ERROR static variables cannot be referenced in a pattern, use a `const` instead
17+
_ => { },
18+
}
19+
}

0 commit comments

Comments
 (0)