}
}
None => {
- cx.sess().bug(format!("can't dereference const of type {}",
+ cx.sess().bug(format!("cannot dereference const of type {}",
ty_to_string(cx.tcx(), t)).as_slice())
}
}
ty::AutoDerefRef(ref adj) => {
let mut ty = ety;
// Save the last autoderef in case we can avoid it.
- for _ in range(0, adj.autoderefs-1) {
- let (dv, dt) = const_deref(cx, llconst, ty, false);
- llconst = dv;
- ty = dt;
+ if adj.autoderefs > 0 {
+ for _ in range(0, adj.autoderefs-1) {
+ let (dv, dt) = const_deref(cx, llconst, ty, false);
+ llconst = dv;
+ ty = dt;
+ }
}
match adj.autoref {
// work properly.
let (_, dt) = const_deref(cx, llconst, ty, false);
ty = dt;
+ } else {
+ llconst = const_addr_of(cx, llconst, ast::MutImmutable)
}
match ty::get(ty).sty {
static x : [int, ..4] = [1,2,3,4];
static y : &'static [int] = &[1,2,3,4];
+static z : &'static [int, ..4] = &[1,2,3,4];
+static zz : &'static [int] = [1,2,3,4];
pub fn main() {
println!("{:?}", x[1]);
println!("{:?}", y[1]);
+ println!("{:?}", z[1]);
+ println!("{:?}", zz[1]);
assert_eq!(x[1], 2);
assert_eq!(x[3], 4);
assert_eq!(x[3], y[3]);
+ assert_eq!(z[1], 2);
+ assert_eq!(z[3], 4);
+ assert_eq!(z[3], y[3]);
+ assert_eq!(zz[1], 2);
+ assert_eq!(zz[3], 4);
+ assert_eq!(zz[3], y[3]);
}