auto merge of #14073 : alexcrichton/rust/snapshots, r=huonw
This commit is contained in:
commit
1001635dc1
@ -137,7 +137,7 @@ pub trait TyVisitor {
|
||||
sz: uint, align: uint) -> bool;
|
||||
|
||||
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;
|
||||
fn visit_enter_enum_variant(&mut self, variant: uint,
|
||||
disr_val: Disr,
|
||||
@ -149,7 +149,7 @@ pub trait TyVisitor {
|
||||
n_fields: uint,
|
||||
name: &str) -> bool;
|
||||
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;
|
||||
|
||||
fn visit_enter_fn(&mut self, purity: uint, proto: uint,
|
||||
|
@ -149,7 +149,7 @@ fn last_error() -> io::IoError {
|
||||
#[cfg(unix)] unsafe fn close(sock: sock_t) { let _ = libc::close(sock); }
|
||||
|
||||
fn sockname(fd: sock_t,
|
||||
f: extern "system" unsafe fn(sock_t, *mut libc::sockaddr,
|
||||
f: unsafe extern "system" fn(sock_t, *mut libc::sockaddr,
|
||||
*mut libc::socklen_t) -> libc::c_int)
|
||||
-> IoResult<ip::SocketAddr>
|
||||
{
|
||||
|
@ -236,12 +236,7 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
|
||||
ident: Option<ast::Ident>,
|
||||
sig: &ty::FnSig)
|
||||
-> ~str {
|
||||
let mut s = if abi == abi::Rust {
|
||||
StrBuf::new()
|
||||
} else {
|
||||
StrBuf::from_owned_str(format!("extern {} ", abi.to_str()))
|
||||
};
|
||||
|
||||
let mut s = StrBuf::new();
|
||||
match fn_style {
|
||||
ast::NormalFn => {}
|
||||
_ => {
|
||||
@ -250,6 +245,10 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
|
||||
}
|
||||
};
|
||||
|
||||
if abi != abi::Rust {
|
||||
s.push_str(format!("extern {} ", abi.to_str()));
|
||||
};
|
||||
|
||||
s.push_str("fn");
|
||||
|
||||
match ident {
|
||||
|
@ -512,32 +512,6 @@ pub use self::num::RadixFmt;
|
||||
mod num;
|
||||
pub mod rt;
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[allow(missing_doc)]
|
||||
pub mod parse {
|
||||
#[deriving(Eq)]
|
||||
pub enum Alignment {
|
||||
AlignLeft,
|
||||
AlignRight,
|
||||
AlignUnknown,
|
||||
}
|
||||
|
||||
pub enum PluralKeyword {
|
||||
Zero,
|
||||
One,
|
||||
Two,
|
||||
Few,
|
||||
Many,
|
||||
}
|
||||
|
||||
pub enum Flag {
|
||||
FlagSignPlus,
|
||||
FlagSignMinus,
|
||||
FlagAlternate,
|
||||
FlagSignAwareZeroPad,
|
||||
}
|
||||
}
|
||||
|
||||
pub type Result = io::IoResult<()>;
|
||||
|
||||
/// A struct to represent both where to emit formatting strings to and how they
|
||||
|
@ -19,15 +19,6 @@
|
||||
|
||||
use option::Option;
|
||||
|
||||
#[cfg(stage0)]
|
||||
pub use fmt::parse::{Alignment, AlignLeft, AlignRight, AlignUnknown};
|
||||
#[cfg(stage0)]
|
||||
pub use fmt::parse::{PluralKeyword, Zero, One, Two, Few, Many};
|
||||
#[cfg(stage0)]
|
||||
pub use fmt::parse::{Flag, FlagSignPlus, FlagSignMinus, FlagSignAwareZeroPad};
|
||||
#[cfg(stage0)]
|
||||
pub use fmt::parse::{FlagAlternate};
|
||||
|
||||
pub enum Piece<'a> {
|
||||
String(&'a str),
|
||||
// FIXME(#8259): this shouldn't require the unit-value here
|
||||
@ -49,7 +40,6 @@ pub struct FormatSpec {
|
||||
pub width: Count,
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[deriving(Eq)]
|
||||
pub enum Alignment {
|
||||
AlignLeft,
|
||||
@ -65,7 +55,6 @@ pub enum Position {
|
||||
ArgumentNext, ArgumentIs(uint)
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
pub enum Flag {
|
||||
FlagSignPlus,
|
||||
FlagSignMinus,
|
||||
|
@ -367,7 +367,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
|
||||
}
|
||||
|
||||
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 {
|
||||
self.align(align);
|
||||
@ -408,7 +408,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
|
||||
}
|
||||
|
||||
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 {
|
||||
if ! self.inner.visit_leave_enum(n_variants, get_disr, sz, align) {
|
||||
return false;
|
||||
|
@ -464,7 +464,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
|
||||
|
||||
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 {
|
||||
let disr = unsafe {
|
||||
@ -538,7 +538,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
|
||||
|
||||
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 {
|
||||
|
@ -294,7 +294,7 @@ mod imp {
|
||||
#[cfg(target_os = "linux")]
|
||||
fn min_stack_size(attr: *libc::pthread_attr_t) -> libc::size_t {
|
||||
use ptr::RawPtr;
|
||||
type F = extern "C" unsafe fn(*libc::pthread_attr_t) -> libc::size_t;
|
||||
type F = unsafe extern "C" fn(*libc::pthread_attr_t) -> libc::size_t;
|
||||
extern {
|
||||
#[linkage = "extern_weak"]
|
||||
static __pthread_get_minstack: *();
|
||||
|
@ -907,12 +907,6 @@ impl<'a> Parser<'a> {
|
||||
abi::Rust
|
||||
};
|
||||
|
||||
// NOTE: remove after a stage0 snapshot
|
||||
let fn_style = match self.parse_unsafety() {
|
||||
UnsafeFn => UnsafeFn,
|
||||
NormalFn => fn_style,
|
||||
};
|
||||
|
||||
self.expect_keyword(keywords::Fn);
|
||||
let (decl, lifetimes) = self.parse_ty_fn_decl(true);
|
||||
return TyBareFn(@BareFnTy {
|
||||
|
@ -2087,13 +2087,13 @@ impl<'a> State<'a> {
|
||||
if opt_sigil == Some('~') && onceness == ast::Once {
|
||||
try!(word(&mut self.s, "proc"));
|
||||
} else if opt_sigil == Some('&') {
|
||||
try!(self.print_extern_opt_abi(opt_abi));
|
||||
try!(self.print_fn_style(fn_style));
|
||||
try!(self.print_extern_opt_abi(opt_abi));
|
||||
try!(self.print_onceness(onceness));
|
||||
} else {
|
||||
assert!(opt_sigil.is_none());
|
||||
try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi));
|
||||
try!(self.print_fn_style(fn_style));
|
||||
try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi));
|
||||
try!(self.print_onceness(onceness));
|
||||
try!(word(&mut self.s, "fn"));
|
||||
}
|
||||
|
@ -1,3 +1,11 @@
|
||||
S 2014-05-09 47ecc2e
|
||||
freebsd-x86_64 5c085972690e1f9412c3c0c7ec64f6b148fe04fd
|
||||
linux-i386 690d2e310c025f10c54b1f2b9f32c65ea34575ed
|
||||
linux-x86_64 b869118e628589d6546a4716c91e1a41952f294c
|
||||
macos-i386 29a044bdd539355fde013797d600bb70c9d05009
|
||||
macos-x86_64 b88ce60be4f70b014669103cb39c8f65814ae311
|
||||
winnt-i386 0da39548596d0596c1c9fb98382c5225d36f4b44
|
||||
|
||||
S 2014-05-06 24f6f26
|
||||
freebsd-x86_64 cebcfcece5676c9aea30241bf13c517ffdb37b7c
|
||||
linux-i386 e9960c7c793ff7ae87c9d30c88cfedf7e40345f7
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user