Added miri error for evaluating foreign statics.

Updated tests accordingly.
This commit is contained in:
Alexander Regueiro 2018-05-29 01:38:18 +01:00
parent 13931762e9
commit 349d53c2a9
14 changed files with 27 additions and 23 deletions

View file

@ -29,7 +29,6 @@ static Y: u32 = 0;
const fn get_Y() -> u32 {
Y
//~^ ERROR E0013
//~| ERROR cannot refer to statics by value
}
const fn get_Y_addr() -> &'static u32 {
@ -49,5 +48,4 @@ const fn get() -> u32 {
//~| ERROR let bindings in constant functions are unstable
}
fn main() {
}
fn main() {}

View file

@ -13,6 +13,7 @@
extern {
pub static symbol: ();
}
static CRASH: () = symbol; //~ cannot refer to other statics by value
static CRASH: () = symbol;
//~^ ERROR constant evaluation error
fn main() {}

View file

@ -22,14 +22,13 @@ static T4: &'static usize = &S;
const T5: usize = C;
const T6: usize = S; //~ ERROR: constants cannot refer to statics
//~^ cannot refer to statics
static T7: usize = C;
static T8: usize = S; //~ ERROR: cannot refer to other statics by value
static T8: usize = S;
const T9: Struct = Struct { a: C };
const T10: Struct = Struct { a: S }; //~ ERROR: cannot refer to statics by value
const T10: Struct = Struct { a: S };
//~^ ERROR: constants cannot refer to statics
static T11: Struct = Struct { a: C };
static T12: Struct = Struct { a: S }; //~ ERROR: cannot refer to other statics by value
static T12: Struct = Struct { a: S };
fn main() {}

View file

@ -15,6 +15,6 @@ extern {
}
pub static BAZ: u32 = *&error_message_count;
//~^ ERROR cannot refer to other statics by value
//~^ ERROR constant evaluation error
fn main() {}

View file

@ -15,14 +15,12 @@ static A: u32 = 1;
static B: u32 = A;
//~^ ERROR thread-local statics cannot be accessed at compile-time
//~| ERROR cannot refer to other statics by value
static C: &u32 = &A;
//~^ ERROR thread-local statics cannot be accessed at compile-time
const D: u32 = A;
//~^ ERROR thread-local statics cannot be accessed at compile-time
//~| ERROR cannot refer to statics by value
const E: &u32 = &A;
//~^ ERROR thread-local statics cannot be accessed at compile-time
@ -30,7 +28,6 @@ const E: &u32 = &A;
const fn f() -> u32 {
A
//~^ ERROR thread-local statics cannot be accessed at compile-time
//~| ERROR cannot refer to statics by value
}
fn main() {}

View file

@ -11,9 +11,6 @@
#![allow(dead_code, warnings)]
static mut x: isize = 3;
static mut y: isize = unsafe {
x
//~^ ERROR cannot refer to other statics by value, use the address-of operator or a constant instea
};
static mut y: isize = unsafe { x };
fn main() {}

View file

@ -10,7 +10,7 @@
struct S { a: usize }
static A: S = S { a: 3 };
static A: S = S { a: 3 };
static B: &'static usize = &A.a;
static C: &'static usize = &(A.a);
@ -18,4 +18,10 @@ static D: [usize; 1] = [1];
static E: usize = D[0];
static F: &'static usize = &D[0];
fn main() {}
fn main() {
assert_eq!(*B, A.a);
assert_eq!(*B, A.a);
assert_eq!(E, D[0]);
assert_eq!(*F, D[0]);
}

View file

@ -16,6 +16,5 @@ struct A {
static B: &'static A = &A { a: &() };
static C: &'static A = &B;
//~^ ERROR cannot refer to other statics by value
fn main() {}

View file

@ -10,6 +10,5 @@
static x: &'static usize = &1;
static y: usize = *x;
//~^ ERROR cannot refer to other statics by value,
// use the address-of operator or a constant instead
fn main() {}