auto merge of #14073 : alexcrichton/rust/snapshots, r=huonw

This commit is contained in:
bors 2014-05-10 09:56:34 -07:00
commit 1001635dc1
15 changed files with 33 additions and 69 deletions

View file

@ -23,13 +23,13 @@ fn main() {
foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
let x: extern "C" unsafe fn(f: int, x: u8) = foo;
//~^ ERROR: mismatched types: expected `extern "C" unsafe fn(int, u8)`
// but found `extern "C" unsafe fn(int, u8, ...)`
let x: unsafe extern "C" fn(f: int, x: u8) = foo;
//~^ ERROR: mismatched types: expected `unsafe extern "C" fn(int, u8)`
// but found `unsafe extern "C" fn(int, u8, ...)`
// (expected non-variadic fn but found variadic function)
let y: extern "C" unsafe fn(f: int, x: u8, ...) = bar;
//~^ ERROR: mismatched types: expected `extern "C" unsafe fn(int, u8, ...)`
let y: unsafe extern "C" fn(f: int, x: u8, ...) = bar;
//~^ ERROR: mismatched types: expected `unsafe extern "C" fn(int, u8, ...)`
// but found `extern "C" extern fn(int, u8)`
// (expected variadic fn but found non-variadic function)

View file

@ -17,5 +17,5 @@ extern {
pub fn main() {
// Will only type check if the type of _p and the decl of printf use the same ABI
let _p: extern unsafe fn() = printf;
let _p: unsafe extern fn() = printf;
}

View file

@ -106,7 +106,7 @@ impl TyVisitor for MyVisitor {
_sz: uint, _align: uint) -> bool { true }
fn visit_enter_enum(&mut self, _n_variants: uint,
_get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
_get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
_sz: uint, _align: uint) -> bool { true }
fn visit_enter_enum_variant(&mut self,
_variant: uint,
@ -122,7 +122,7 @@ impl TyVisitor for MyVisitor {
_name: &str) -> bool { true }
fn visit_leave_enum(&mut self,
_n_variants: uint,
_get_disr: extern unsafe fn(ptr: *Opaque) -> Disr,
_get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
_sz: uint, _align: uint) -> bool { true }
fn visit_enter_fn(&mut self, _purity: uint, _proto: uint,

View file

@ -41,10 +41,10 @@ pub fn main() {
});
// Make a function pointer
let x: extern "C" unsafe fn(*mut c_char, *c_char, ...) -> c_int = sprintf;
let x: unsafe extern "C" fn(*mut c_char, *c_char, ...) -> c_int = sprintf;
// A function that takes a function pointer
unsafe fn call(p: extern "C" unsafe fn(*mut c_char, *c_char, ...) -> c_int) {
unsafe fn call(p: unsafe extern "C" fn(*mut c_char, *c_char, ...) -> c_int) {
// Call with just the named parameter via fn pointer
"Hello World\n".with_c_str(|c| {
check("Hello World\n", |s| p(s, c));