mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 05:57:03 +03:00
organize compile-fail tests in folders
This commit is contained in:
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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 ()
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user