File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -5073,10 +5073,15 @@ impl<'a> Resolver<'a> {
5073
5073
Some ( def @ ( DefFn ( ..) , _) ) |
5074
5074
Some ( def @ ( DefVariant ( ..) , _) ) |
5075
5075
Some ( def @ ( DefStruct ( ..) , _) ) |
5076
- Some ( def @ ( DefConst ( ..) , _) ) |
5077
- Some ( def @ ( DefStatic ( ..) , _) ) => {
5076
+ Some ( def @ ( DefConst ( ..) , _) ) => {
5078
5077
self . record_def ( pattern. id , def) ;
5079
5078
}
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
+ }
5080
5085
Some ( _) => {
5081
5086
self . resolve_error ( path. span ,
5082
5087
format ! ( "`{}` is not an enum variant, struct or const" ,
Original file line number Diff line number Diff line change
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 = 1 u;
12
+
13
+ fn main ( ) {
14
+ match 1 u {
15
+ self :: X => { } ,
16
+ //~^ ERROR static variables cannot be referenced in a pattern, use a `const` instead
17
+ _ => { } ,
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments