Fixed bug with miri const evaluation where allocation is recursively borrowed.

This commit is contained in:
Alexander Regueiro
2018-05-30 19:27:45 +01:00
parent 349d53c2a9
commit a2cd95fd9e
4 changed files with 3 additions and 7 deletions
+2 -1
View File
@@ -305,7 +305,8 @@ pub fn get(&self, id: AllocId) -> EvalResult<'tcx, &Allocation> {
Some(alloc) => Ok(alloc),
None => {
// static alloc?
match self.tcx.alloc_map.lock().get(id) {
let alloc = self.tcx.alloc_map.lock().get(id);
match alloc {
Some(AllocType::Memory(mem)) => Ok(mem),
Some(AllocType::Function(..)) => {
Err(EvalErrorKind::DerefFunctionPointer.into())
+1
View File
@@ -16,5 +16,6 @@
pub static BAZ: u32 = *&error_message_count;
//~^ ERROR constant evaluation error
//~| tried to read foreign (extern) static
fn main() {}
@@ -15,13 +15,7 @@
use array::ARRAY;
static X: &'static u8 = &ARRAY[0];
//~^ ERROR: cannot refer to the interior of another static, use a constant
static Y: &'static u8 = &(&ARRAY)[0];
//~^ ERROR: cannot refer to the interior of another static, use a constant
static Z: u8 = (&ARRAY)[0];
//~^ ERROR: cannot refer to the interior of another static, use a constant
//~^^ ERROR: cannot refer to other statics by value
pub fn main() {}