Fix a couple of tests

This commit is contained in:
bjorn3 2018-05-09 15:54:45 +02:00
parent 9ba64e290a
commit 3db0568c40
29 changed files with 60 additions and 85 deletions

View File

@ -10,8 +10,6 @@
#![feature(core_intrinsics)]
use std::intrinsics::*;
//error-pattern: copy_nonoverlapping called on overlapping ranges
fn main() {

View File

@ -2,14 +2,14 @@
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
use alloc::alloc::Global;
use std::alloc::*;
// error-pattern: incorrect alloc info: expected size 1 and align 2, got size 1 and align 1
fn main() {
unsafe {
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Heap.dealloc(x, Layout::from_size_align_unchecked(1, 2));
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
Global.dealloc(x, Layout::from_size_align_unchecked(1, 2));
}
}

View File

@ -2,14 +2,14 @@
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
use alloc::alloc::Global;
use std::alloc::*;
// error-pattern: incorrect alloc info: expected size 2 and align 1, got size 1 and align 1
fn main() {
unsafe {
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Heap.dealloc(x, Layout::from_size_align_unchecked(2, 1));
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
Global.dealloc(x, Layout::from_size_align_unchecked(2, 1));
}
}

View File

@ -2,15 +2,15 @@
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
use alloc::alloc::Global;
use std::alloc::*;
// error-pattern: tried to deallocate dangling pointer
fn main() {
unsafe {
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
}
}

View File

@ -1,17 +0,0 @@
// This should fail even without validation
// compile-flags: -Zmir-emit-validate=0
#![feature(never_type)]
#![allow(unreachable_code)]
#![allow(unused_variables)]
struct Human;
fn main() {
let x: ! = unsafe {
std::mem::transmute::<Human, !>(Human) //~ ERROR entered unreachable code
};
f(x)
}
fn f(x: !) -> ! { x }

View File

@ -1,4 +1,4 @@
// error-pattern: overflowing math
// error-pattern: attempt to add with overflow
fn main() {
let v = [0i8; 4];
let x = &v as *const i8;

View File

@ -1,4 +1,4 @@
//error-pattern: overflowing math
//error-pattern: attempt to add with overflow
fn main() {
let v = [1i8, 2];
let x = &v[1] as *const i8;

View File

@ -1,16 +0,0 @@
#![feature(alloc, allocator_api)]
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
// error-pattern: incorrect alloc info: expected size 1 and align 2, got size 1 and align 1
fn main() {
unsafe {
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
// Try realloc with a too big alignment.
let _y = Heap.realloc(x, Layout::from_size_align_unchecked(1, 2), Layout::from_size_align_unchecked(1, 1)).unwrap();
}
}

View File

@ -1,16 +0,0 @@
#![feature(alloc, allocator_api)]
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
// error-pattern: incorrect alloc info: expected size 1 and align 1, got size 1 and align 2
fn main() {
unsafe {
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 2)).unwrap();
// Try realloc with a too small alignment.
let _y = Heap.realloc(x, Layout::from_size_align_unchecked(1, 1), Layout::from_size_align_unchecked(1, 2)).unwrap();
}
}

View File

@ -2,14 +2,14 @@
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
use alloc::alloc::Global;
use std::alloc::*;
// error-pattern: incorrect alloc info: expected size 2 and align 1, got size 1 and align 1
fn main() {
unsafe {
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
let _y = Heap.realloc(x, Layout::from_size_align_unchecked(2, 1), Layout::from_size_align_unchecked(1, 1)).unwrap();
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
let _y = Global.realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
}
}

View File

@ -2,13 +2,13 @@
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
use alloc::alloc::Global;
use std::alloc::*;
fn main() {
unsafe {
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
let _y = Heap.realloc(x, Layout::from_size_align_unchecked(1, 1), Layout::from_size_align_unchecked(1, 1)).unwrap();
let _z = *x; //~ ERROR: dangling pointer was dereferenced
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
let _y = Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
let _z = *(x as *mut u8); //~ ERROR: dangling pointer was dereferenced
}
}

View File

@ -2,15 +2,15 @@
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
use alloc::alloc::Global;
use std::alloc::*;
// error-pattern: dangling pointer was dereferenced
fn main() {
unsafe {
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
Heap.realloc(x, Layout::from_size_align_unchecked(1, 1), Layout::from_size_align_unchecked(1, 1));
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
}
}

View File

@ -1,5 +1,6 @@
// error-pattern the type `[u8;
fn main() {
let data: [u8; std::usize::MAX] = [42; std::usize::MAX];
//~^ ERROR: rustc layout computation failed: SizeOverflow([u8;
assert_eq!(data.len(), 1024);
}

View File

@ -1,3 +1,5 @@
// ignore-test
fn main() {
let data: [u8; 1024*1024*1024] = [42; 1024*1024*1024];
//~^ ERROR: tried to allocate

View File

@ -1,6 +1,5 @@
// This should fail even without validation
// compile-flags: -Zmir-emit-validate=0
#![feature(i128_type)]
fn main() {
#[cfg(target_pointer_width="64")]
@ -11,5 +10,5 @@ fn main() {
let bad = unsafe {
std::mem::transmute::<&[u8], u64>(&[1u8])
};
bad + 1; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
let _ = bad + 1; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
}

View File

@ -1,5 +1,3 @@
#![feature(i128_type)]
fn main() {
#[cfg(target_pointer_width="64")]
let bad = unsafe {

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
mod safe {

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
mod safe {

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
mod safe {

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
mod safe {

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
// For some reason, the error location is different when using fullmir

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
mod safe {

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
mod safe {

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
// Make sure validation can handle many overlapping shared borrows for different parts of a data structure
#![allow(unused_variables)]
use std::cell::RefCell;

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
static mut PTR: *mut u8 = 0 as *mut _;

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
#[repr(u32)]

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
mod safe {

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
mod safe {

View File

@ -1,3 +1,5 @@
// ignore-test validation_op is disabled
#![allow(unused_variables)]
// error-pattern: attempted to read undefined bytes