diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-10-02 15:06:08 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-10-02 19:37:06 -0700 |
| commit | 7e22af3582aa4a8dcb5b2ac00c7914ef78d2486e (patch) | |
| tree | 2a493a659d2e79f28eae608e33598859b2df7173 /src/test | |
| parent | b2d4eb186e99b66051be9089f836c66a558dd995 (diff) | |
| download | rust-7e22af3582aa4a8dcb5b2ac00c7914ef78d2486e.tar.gz rust-7e22af3582aa4a8dcb5b2ac00c7914ef78d2486e.zip | |
syntax: Enable parsing of `const` globals
This rewrites them to the current `ItemStatic` production of the compiler, but I want to get this into a snapshot. It will be illegal to use a `static` in a pattern of a `match` statement, so all those current uses will need to be rewritten to `const` once it's implemented. This requires that the stage0 snapshot is able to parse `const`. cc #17718
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/issue-17718-const-mut.rs | 17 | ||||
| -rw-r--r-- | src/test/run-pass/issue-17718-parse-const.rs | 15 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-17718-const-mut.rs b/src/test/compile-fail/issue-17718-const-mut.rs new file mode 100644 index 00000000000..31a5fee2044 --- /dev/null +++ b/src/test/compile-fail/issue-17718-const-mut.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const +mut //~ ERROR: const globals cannot be mutable, did you mean to declare a static? +FOO: uint = 3; + +fn main() { +} + diff --git a/src/test/run-pass/issue-17718-parse-const.rs b/src/test/run-pass/issue-17718-parse-const.rs new file mode 100644 index 00000000000..3ca6f473a79 --- /dev/null +++ b/src/test/run-pass/issue-17718-parse-const.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const FOO: uint = 3; + +fn main() { + assert_eq!(FOO, 3); +} |
