Skip to content

Commit 1df0a0b

Browse files
committed
Const dereference works now, so allow it.
1 parent 122e4a2 commit 1df0a0b

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/librustc/middle/check_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ pub fn check_expr(sess: Session,
9191
v: visit::vt<bool>) {
9292
if is_const {
9393
match e.node {
94-
expr_unary(box(_), _) | expr_unary(uniq(_), _) |
95-
expr_unary(deref, _) => {
94+
expr_unary(deref, _) => { }
95+
expr_unary(box(_), _) | expr_unary(uniq(_), _) => {
9696
sess.span_err(e.span,
9797
~"disallowed operator in constant expression");
9898
return;

src/test/run-pass/const-deref.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 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+
const C: &'static int = &1000;
12+
const D: int = *C;
13+
struct S(&'static int);
14+
const E: &'static S = &S(C);
15+
const F: int = ***E;
16+
17+
pub fn main() {
18+
fail_unless!(D == 1000);
19+
fail_unless!(F == 1000);
20+
}

0 commit comments

Comments
 (0)