Const dereference works now, so allow it.

This commit is contained in:
Jed Davis 2013-03-08 12:41:40 -08:00
parent 122e4a28b8
commit 1df0a0ba0f
2 changed files with 22 additions and 2 deletions

View File

@ -91,8 +91,8 @@ pub fn check_expr(sess: Session,
v: visit::vt<bool>) {
if is_const {
match e.node {
expr_unary(box(_), _) | expr_unary(uniq(_), _) |
expr_unary(deref, _) => {
expr_unary(deref, _) => { }
expr_unary(box(_), _) | expr_unary(uniq(_), _) => {
sess.span_err(e.span,
~"disallowed operator in constant expression");
return;

View File

@ -0,0 +1,20 @@
// Copyright 2013 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 C: &'static int = &1000;
const D: int = *C;
struct S(&'static int);
const E: &'static S = &S(C);
const F: int = ***E;
pub fn main() {
fail_unless!(D == 1000);
fail_unless!(F == 1000);
}