organize compile-fail tests in folders

This commit is contained in:
Ralf Jung 2020-04-11 09:30:13 +02:00
parent 910afefcf6
commit b2bf4ec2f5
73 changed files with 2 additions and 2 deletions

View file

@ -0,0 +1,11 @@
// Validation makes this fail in the wrong place
// compile-flags: -Zmiri-disable-validation
fn main() {
let b = Box::new(42);
let g = unsafe {
std::mem::transmute::<&Box<usize>, &fn(i32)>(&b)
};
(*g)(42) //~ ERROR it does not point to a function
}

View file

@ -0,0 +1,9 @@
fn main() {
fn f() {}
let g = unsafe {
std::mem::transmute::<fn(), fn(i32)>(f)
};
g(42) //~ ERROR calling a function with more arguments than it expected
}

View file

@ -0,0 +1,9 @@
fn main() {
fn f(_ : (i32,i32)) {}
let g = unsafe {
std::mem::transmute::<fn((i32,i32)), fn(i32)>(f)
};
g(42) //~ ERROR calling a function with argument of type (i32, i32) passing data of type i32
}

View file

@ -0,0 +1,10 @@
fn main() {
fn f(_ : (i32,i32)) {}
let g = unsafe {
std::mem::transmute::<fn((i32,i32)), fn()>(f)
};
g() //~ ERROR calling a function with fewer arguments than it requires
}

View file

@ -0,0 +1,9 @@
fn main() {
fn f(_ : *const [i32]) {}
let g = unsafe {
std::mem::transmute::<fn(*const [i32]), fn(*const i32)>(f)
};
g(&42 as *const i32) //~ ERROR calling a function with argument of type *const [i32] passing data of type *const i32
}

View file

@ -0,0 +1,9 @@
fn main() {
fn f() -> u32 { 42 }
let g = unsafe {
std::mem::transmute::<fn() -> u32, fn()>(f)
};
g() //~ ERROR calling a function with return type u32 passing return place of type ()
}

View file

@ -0,0 +1,10 @@
// Validation makes this fail in the wrong place
// compile-flags: -Zmiri-disable-validation
fn main() {
let g = unsafe {
std::mem::transmute::<usize, fn(i32)>(42)
};
g(42) //~ ERROR invalid use of 42 as a pointer
}

View file

@ -0,0 +1,8 @@
fn f() {}
fn main() {
let x: u8 = unsafe {
*std::mem::transmute::<fn(), *const u8>(f) //~ ERROR contains a function
};
panic!("this should never print: {}", x);
}

View file

@ -0,0 +1,12 @@
// Validation makes this fail in the wrong place
// compile-flags: -Zmiri-disable-validation
#![feature(box_syntax)]
fn main() {
let x = box 42;
unsafe {
let f = std::mem::transmute::<Box<i32>, fn()>(x);
f() //~ ERROR function pointer but it does not point to a function
}
}

View file

@ -0,0 +1,14 @@
// Validation makes this fail in the wrong place
// compile-flags: -Zmiri-disable-validation
use std::mem;
fn f() {}
fn main() {
let x : fn() = f;
let y : *mut u8 = unsafe { mem::transmute(x) };
let y = y.wrapping_offset(1);
let x : fn() = unsafe { mem::transmute(y) };
x(); //~ ERROR function pointer but it does not point to a function
}