From 4eaa2a457e6ee489a95589448868acf4a4cd65c4 Mon Sep 17 00:00:00 2001 From: wakandan Date: Wed, 18 Sep 2013 23:23:37 +0800 Subject: [PATCH 1/4] remove use of "either" in rt.rs and followingly mod.rs --- src/libstd/fmt/mod.rs | 15 ++++++++------- src/libstd/fmt/rt.rs | 8 ++++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index cad9f14bda734..37d0e2073e6c5 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -396,6 +396,7 @@ use char::Char; use rt::io::Decorator; use rt::io::mem::MemWriter; use rt::io; +use fmt::rt::{Keyword, LiteralNumber}; use str; use sys; use util; @@ -678,7 +679,7 @@ impl<'self> Formatter<'self> { // offsetted value for s in selectors.iter() { match s.selector { - Right(val) if value == val => { + LiteralNumber(val) if value == val => { return self.runplural(value, s.result); } _ => {} @@ -690,17 +691,17 @@ impl<'self> Formatter<'self> { let value = value - match offset { Some(i) => i, None => 0 }; for s in selectors.iter() { let run = match s.selector { - Left(parse::Zero) => value == 0, - Left(parse::One) => value == 1, - Left(parse::Two) => value == 2, + Keyword(parse::Zero) => value == 0, + Keyword(parse::One) => value == 1, + Keyword(parse::Two) => value == 2, // XXX: Few/Many should have a user-specified boundary // One possible option would be in the function // pointer of the 'arg: Argument' struct. - Left(parse::Few) => value < 8, - Left(parse::Many) => value >= 8, + Keyword(parse::Few) => value < 8, + Keyword(parse::Many) => value >= 8, - Right(*) => false + LiteralNumber(*) => false }; if run { return self.runplural(value, s.result); diff --git a/src/libstd/fmt/rt.rs b/src/libstd/fmt/rt.rs index 90763836fc6b6..b973412da00f3 100644 --- a/src/libstd/fmt/rt.rs +++ b/src/libstd/fmt/rt.rs @@ -17,7 +17,6 @@ #[allow(missing_doc)]; #[doc(hidden)]; -use either::Either; use fmt::parse; use option::Option; @@ -51,8 +50,13 @@ pub enum Method<'self> { Select(&'self [SelectArm<'self>], &'self [Piece<'self>]), } +pub enum PluralSelector{ + Keyword(parse::PluralKeyword), + LiteralNumber(uint) +} + pub struct PluralArm<'self> { - selector: Either, + selector: PluralSelector, result: &'self [Piece<'self>], } From eafde3a49aacedb694a53bce67bf3750350f647e Mon Sep 17 00:00:00 2001 From: wakandan Date: Sun, 29 Sep 2013 00:01:16 +0800 Subject: [PATCH 2/4] revert some removal of Either --- src/libstd/fmt/mod.rs | 75 +++++++++++++++++++++---------------------- src/libstd/fmt/rt.rs | 8 ++--- 2 files changed, 39 insertions(+), 44 deletions(-) diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index ed89a39fe55ad..99a5ed4d69812 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -33,14 +33,14 @@ arguments directly while performing minimal allocations. Some examples of the `format!` extension are: -```rust +~~~{.rust} format!("Hello") // => ~"Hello" format!("Hello, {:s}!", "world") // => ~"Hello, world!" format!("The number is {:d}", 1) // => ~"The number is 1" format!("{:?}", ~[3, 4]) // => ~"~[3, 4]" format!("{value}", value=4) // => ~"4" format!("{} {}", 1, 2) // => ~"1 2" - ``` +~~~ From these, you can see that the first argument is a format string. It is required by the compiler for this to be a string literal; it cannot be a @@ -67,9 +67,9 @@ function, but the `format!` macro is a syntax extension which allows it to leverage named parameters. Named parameters are listed at the end of the argument list and have the syntax: - ``` +~~~ identifier '=' expression - ``` +~~~ It is illegal to put positional parameters (those without names) after arguments which have names. Like positional parameters, it is illegal to provided named @@ -84,9 +84,9 @@ and if all references to one argument do not provide a type, then the format `?` is used (the type's rust-representation is printed). For example, this is an invalid format string: - ``` +~~~ {0:d} {0:s} - ``` +~~~ Because the first argument is both referred to as an integer as well as a string. @@ -100,9 +100,9 @@ must have the type `uint`. Although a `uint` can be printed with `{:u}`, it is illegal to reference an argument as such. For example, this is another invalid format string: - ``` +~~~ {:.*s} {0:u} - ``` +~~~ ### Formatting traits @@ -134,9 +134,9 @@ is `?` which is defined for all types by default. When implementing a format trait for your own time, you will have to implement a method of the signature: -```rust +~~~{.rust} fn fmt(value: &T, f: &mut std::fmt::Formatter); - ``` +~~~ Your type will be passed by-reference in `value`, and then the function should emit output into the `f.buf` stream. It is up to each format trait @@ -150,14 +150,14 @@ helper methods. There are a number of related macros in the `format!` family. The ones that are currently implemented are: -```rust +~~~{.rust} format! // described above write! // first argument is a &mut rt::io::Writer, the destination writeln! // same as write but appends a newline print! // the format string is printed to the standard output println! // same as print but appends a newline format_args! // described below. - ``` +~~~ #### `write!` @@ -167,12 +167,12 @@ specified stream. This is used to prevent intermediate allocations of format strings and instead directly write the output. Under the hood, this function is actually invoking the `write` function defined in this module. Example usage is: -```rust +~~~{.rust} use std::rt::io; let mut w = io::mem::MemWriter::new(); write!(&mut w as &mut io::Writer, "Hello {}!", "world"); - ``` +~~~ #### `print!` @@ -180,10 +180,10 @@ This and `println` emit their output to stdout. Similarly to the `write!` macro, the goal of these macros is to avoid intermediate allocations when printing output. Example usage is: -```rust +~~~{.rust} print!("Hello {}!", "world"); println!("I have a newline {}", "character at the end"); - ``` +~~~ #### `format_args!` This is a curious macro which is used to safely pass around @@ -193,13 +193,13 @@ references information on the stack. Under the hood, all of the related macros are implemented in terms of this. First off, some example usage is: -```rust +~~~{.rust} use std::fmt; format_args!(fmt::format, "this returns {}", "~str"); format_args!(|args| { fmt::write(my_writer, args) }, "some {}", "args"); format_args!(my_fn, "format {}", "string"); - ``` +~~~ The first argument of the `format_args!` macro is a function (or closure) which takes one argument of type `&fmt::Arguments`. This structure can then be @@ -236,9 +236,9 @@ Furthermore, whenever a case is running, the special character `#` can be used to reference the string value of the argument which was selected upon. As an example: -```rust +~~~{.rust} format!("{0, select, other{#}}", "hello") // => ~"hello" - ``` +~~~ This example is the equivalent of `{0:s}` essentially. @@ -247,9 +247,9 @@ This example is the equivalent of `{0:s}` essentially. The select method is a switch over a `&str` parameter, and the parameter *must* be of the type `&str`. An example of the syntax is: - ``` +~~~ {0, select, male{...} female{...} other{...}} - ``` +~~~ Breaking this down, the `0`-th argument is selected upon with the `select` method, and then a number of cases follow. Each case is preceded by an @@ -266,9 +266,9 @@ The plural method is a switch statement over a `uint` parameter, and the parameter *must* be a `uint`. A plural method in its full glory can be specified as: - ``` +~~~ {0, plural, offset=1 =1{...} two{...} many{...} other{...}} - ``` +~~~ To break this down, the first `0` indicates that this method is selecting over the value of the first positional parameter to the format string. Next, the @@ -294,7 +294,7 @@ should not be too alien. Arguments are formatted with python-like syntax, meaning that arguments are surrounded by `{}` instead of the C-like `%`. The actual grammar for the formatting syntax is: - ``` +~~~ format_string := [ format ] * format := '{' [ argument ] [ ':' format_spec ] [ ',' function_spec ] '}' argument := integer | identifier @@ -315,7 +315,7 @@ plural := 'plural' ',' [ 'offset:' integer ] ( selector arm ) * selector := '=' integer | keyword keyword := 'zero' | 'one' | 'two' | 'few' | 'many' | 'other' arm := '{' format_string '}' - ``` +~~~ ## Formatting Parameters @@ -397,7 +397,6 @@ use char::Char; use rt::io::Decorator; use rt::io::mem::MemWriter; use rt::io; -use fmt::rt::{Keyword, LiteralNumber}; use str; use sys; use util; @@ -517,11 +516,11 @@ pub trait Float { fn fmt(&Self, &mut Formatter); } /// /// # Example /// -/// ```rust +/// ~~~{.rust} /// use std::fmt; /// let w: &mut io::Writer = ...; /// format_args!(|args| { fmt::write(w, args) }, "Hello, {}!", "world"); -/// ``` +/// ~~~ pub fn write(output: &mut io::Writer, args: &Arguments) { unsafe { write_unsafe(output, args.fmt, args.args) } } @@ -582,11 +581,11 @@ pub unsafe fn write_unsafe(output: &mut io::Writer, /// /// # Example /// -/// ```rust +/// ~~~{.rust} /// use std::fmt; /// let s = format_args!(fmt::format, "Hello, {}!", "world"); /// assert_eq!(s, "Hello, world!"); -/// ``` +/// ~~~ pub fn format(args: &Arguments) -> ~str { unsafe { format_unsafe(args.fmt, args.args) } } @@ -680,7 +679,7 @@ impl<'self> Formatter<'self> { // offsetted value for s in selectors.iter() { match s.selector { - LiteralNumber(val) if value == val => { + Right(val) if value == val => { return self.runplural(value, s.result); } _ => {} @@ -692,17 +691,17 @@ impl<'self> Formatter<'self> { let value = value - match offset { Some(i) => i, None => 0 }; for s in selectors.iter() { let run = match s.selector { - Keyword(parse::Zero) => value == 0, - Keyword(parse::One) => value == 1, - Keyword(parse::Two) => value == 2, + Left(parse::Zero) => value == 0, + Left(parse::One) => value == 1, + Left(parse::Two) => value == 2, // XXX: Few/Many should have a user-specified boundary // One possible option would be in the function // pointer of the 'arg: Argument' struct. - Keyword(parse::Few) => value < 8, - Keyword(parse::Many) => value >= 8, + Left(parse::Few) => value < 8, + Left(parse::Many) => value >= 8, - LiteralNumber(*) => false + Right(*) => false }; if run { return self.runplural(value, s.result); diff --git a/src/libstd/fmt/rt.rs b/src/libstd/fmt/rt.rs index b973412da00f3..90763836fc6b6 100644 --- a/src/libstd/fmt/rt.rs +++ b/src/libstd/fmt/rt.rs @@ -17,6 +17,7 @@ #[allow(missing_doc)]; #[doc(hidden)]; +use either::Either; use fmt::parse; use option::Option; @@ -50,13 +51,8 @@ pub enum Method<'self> { Select(&'self [SelectArm<'self>], &'self [Piece<'self>]), } -pub enum PluralSelector{ - Keyword(parse::PluralKeyword), - LiteralNumber(uint) -} - pub struct PluralArm<'self> { - selector: PluralSelector, + selector: Either, result: &'self [Piece<'self>], } From bd2c4e6882cd230be2989c40a4a0d502a310568a Mon Sep 17 00:00:00 2001 From: wakandan Date: Sun, 29 Sep 2013 00:02:10 +0800 Subject: [PATCH 3/4] fix #9483, Remove #[abi = "foo"] attributes from codebase. --- src/libextra/time.rs | 3 +-- src/libextra/unicode.rs | 3 +-- src/librustc/lib/llvm.rs | 3 +-- src/libstd/os.rs | 4 ---- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/libextra/time.rs b/src/libextra/time.rs index d51d1c2178571..ff9f8b2c5810b 100644 --- a/src/libextra/time.rs +++ b/src/libextra/time.rs @@ -19,8 +19,7 @@ static NSEC_PER_SEC: i32 = 1_000_000_000_i32; pub mod rustrt { use super::Tm; - #[abi = "cdecl"] - extern { + extern "cdecl" { pub fn get_time(sec: &mut i64, nsec: &mut i32); pub fn precise_time_ns(ns: &mut u64); pub fn rust_tzset(); diff --git a/src/libextra/unicode.rs b/src/libextra/unicode.rs index 3957551c84639..1f85003226668 100644 --- a/src/libextra/unicode.rs +++ b/src/libextra/unicode.rs @@ -162,8 +162,7 @@ pub mod icu { // #[link_name = "icuuc"] #[link_args = "-licuuc"] - #[abi = "cdecl"] - extern { + extern "cdecl" { pub fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool; pub fn u_isdigit(c: UChar32) -> UBool; pub fn u_islower(c: UChar32) -> UBool; diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 49798288d40d0..7fc316b2d9373 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -298,8 +298,7 @@ pub mod llvm { #[link_args = "-Lrustllvm -lrustllvm"] #[link_name = "rustllvm"] - #[abi = "cdecl"] - extern { + extern "cdecl" { /* Create and destroy contexts. */ #[fast_ffi] pub fn LLVMContextCreate() -> ContextRef; diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 08a1f879e7804..2a3ad98c02b43 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1041,7 +1041,6 @@ pub fn errno() -> uint { #[cfg(target_arch = "x86")] #[link_name = "kernel32"] - #[abi = "stdcall"] extern "stdcall" { fn GetLastError() -> DWORD; } @@ -1120,7 +1119,6 @@ pub fn last_os_error() -> ~str { #[cfg(target_arch = "x86")] #[link_name = "kernel32"] - #[abi = "stdcall"] extern "stdcall" { fn FormatMessageW(flags: DWORD, lpSrc: LPVOID, @@ -1260,7 +1258,6 @@ type LPCWSTR = *u16; #[cfg(windows, target_arch = "x86")] #[link_name="kernel32"] -#[abi="stdcall"] extern "stdcall" { fn GetCommandLineW() -> LPCWSTR; fn LocalFree(ptr: *c_void); @@ -1275,7 +1272,6 @@ extern { #[cfg(windows, target_arch = "x86")] #[link_name="shell32"] -#[abi="stdcall"] extern "stdcall" { fn CommandLineToArgvW(lpCmdLine: LPCWSTR, pNumArgs: *mut c_int) -> **u16; } From 1dc18b8a49f26e1f906a5d972f53cc2a67e0b8a1 Mon Sep 17 00:00:00 2001 From: wakandan Date: Sun, 29 Sep 2013 11:29:34 +0800 Subject: [PATCH 4/4] fix i#9483, Remove #[abi = "foo"] attributes from codebase. --- src/libstd/io.rs | 3 +- src/libstd/libc.rs | 76 ++++++------------- src/libstd/num/cmath.rs | 6 +- src/libstd/rand/mod.rs | 3 +- src/libstd/rt/thread_local_storage.rs | 1 - src/libstd/run.rs | 3 +- src/libstd/unstable/intrinsics.rs | 1 - .../anon-extern-mod-cross-crate-1.rs | 3 +- src/test/auxiliary/cci_intrinsic.rs | 1 - .../compile-fail/foreign-unsafe-fn-called.rs | 3 +- src/test/run-pass/anon-extern-mod.rs | 3 +- src/test/run-pass/c-stack-as-value.rs | 3 +- src/test/run-pass/c-stack-returning-int64.rs | 3 +- src/test/run-pass/conditional-compile.rs | 9 +-- src/test/run-pass/foreign-dupe.rs | 6 +- src/test/run-pass/foreign-fn-linkname.rs | 3 +- src/test/run-pass/foreign2.rs | 12 +-- src/test/run-pass/intrinsic-alignment.rs | 1 - src/test/run-pass/intrinsic-atomics.rs | 1 - src/test/run-pass/intrinsic-frame-address.rs | 1 - src/test/run-pass/intrinsic-move-val.rs | 1 - src/test/run-pass/intrinsic-uninit.rs | 1 - src/test/run-pass/intrinsics-integer.rs | 1 - src/test/run-pass/intrinsics-math.rs | 1 - src/test/run-pass/issue-2214.rs | 3 +- src/test/run-pass/item-attributes.rs | 15 ++-- src/test/run-pass/morestack-address.rs | 1 - src/test/run-pass/rec-align-u32.rs | 1 - src/test/run-pass/rec-align-u64.rs | 1 - src/test/run-pass/x86stdcall2.rs | 1 - 30 files changed, 51 insertions(+), 117 deletions(-) diff --git a/src/libstd/io.rs b/src/libstd/io.rs index 859cf20fa4184..74959f180c4ec 100644 --- a/src/libstd/io.rs +++ b/src/libstd/io.rs @@ -76,9 +76,8 @@ pub type fd_t = c_int; pub mod rustrt { use libc; - #[abi = "cdecl"] #[link_name = "rustrt"] - extern { + extern "cdecl" { pub fn rust_get_stdin() -> *libc::FILE; pub fn rust_get_stdout() -> *libc::FILE; pub fn rust_get_stderr() -> *libc::FILE; diff --git a/src/libstd/libc.rs b/src/libstd/libc.rs index e772ade135ec3..f8ae79e7990fa 100644 --- a/src/libstd/libc.rs +++ b/src/libstd/libc.rs @@ -2664,11 +2664,10 @@ pub mod funcs { pub mod c95 { #[nolink] - #[abi = "cdecl"] pub mod ctype { use libc::types::os::arch::c95::{c_char, c_int}; - extern { + extern "cdecl" { pub fn isalnum(c: c_int) -> c_int; pub fn isalpha(c: c_int) -> c_int; pub fn iscntrl(c: c_int) -> c_int; @@ -2686,12 +2685,11 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod stdio { use libc::types::common::c95::{FILE, c_void, fpos_t}; use libc::types::os::arch::c95::{c_char, c_int, c_long, size_t}; - extern { + extern "cdecl" { pub fn fopen(filename: *c_char, mode: *c_char) -> *FILE; pub fn freopen(filename: *c_char, mode: *c_char, file: *FILE) -> *FILE; @@ -2748,14 +2746,13 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod stdlib { use libc::types::common::c95::c_void; use libc::types::os::arch::c95::{c_char, c_double, c_int}; use libc::types::os::arch::c95::{c_long, c_uint, c_ulong}; use libc::types::os::arch::c95::{size_t}; - extern { + extern "cdecl" { pub fn abs(i: c_int) -> c_int; pub fn labs(i: c_long) -> c_long; // Omitted: div, ldiv (return pub type incomplete). @@ -2786,13 +2783,12 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod string { use libc::types::common::c95::c_void; use libc::types::os::arch::c95::{c_char, c_int, size_t}; use libc::types::os::arch::c95::{wchar_t}; - extern { + extern "cdecl" { pub fn strcpy(dst: *c_char, src: *c_char) -> *c_char; pub fn strncpy(dst: *c_char, src: *c_char, n: size_t) -> *c_char; @@ -2836,12 +2832,11 @@ pub mod funcs { #[cfg(target_os = "win32")] pub mod posix88 { #[nolink] - #[abi = "cdecl"] pub mod stat_ { use libc::types::os::common::posix01::stat; use libc::types::os::arch::c95::{c_int, c_char}; - extern { + extern "cdecl" { #[link_name = "_chmod"] pub fn chmod(path: *c_char, mode: c_int) -> c_int; #[link_name = "_mkdir"] @@ -2854,12 +2849,11 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod stdio { use libc::types::common::c95::FILE; use libc::types::os::arch::c95::{c_int, c_char}; - extern { + extern "cdecl" { #[link_name = "_popen"] pub fn popen(command: *c_char, mode: *c_char) -> *FILE; #[link_name = "_pclose"] @@ -2873,10 +2867,9 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod fcntl { use libc::types::os::arch::c95::{c_int, c_char}; - extern { + extern "cdecl" { #[link_name = "_open"] pub fn open(path: *c_char, oflag: c_int, mode: c_int) -> c_int; @@ -2886,20 +2879,18 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod dirent { // Not supplied at all. } #[nolink] - #[abi = "cdecl"] pub mod unistd { use libc::types::common::c95::c_void; use libc::types::os::arch::c95::{c_int, c_uint, c_char, c_long, size_t}; use libc::types::os::arch::c99::intptr_t; - extern { + extern "cdecl" { #[link_name = "_access"] pub fn access(path: *c_char, amode: c_int) -> c_int; #[link_name = "_chdir"] @@ -2962,8 +2953,7 @@ pub mod funcs { use libc::types::os::arch::posix88::mode_t; #[nolink] - #[abi = "cdecl"] - extern { + extern "cdecl" { pub fn chmod(path: *c_char, mode: mode_t) -> c_int; pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; @@ -2991,12 +2981,11 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod stdio { use libc::types::common::c95::FILE; use libc::types::os::arch::c95::{c_char, c_int}; - extern { + extern "cdecl" { pub fn popen(command: *c_char, mode: *c_char) -> *FILE; pub fn pclose(stream: *FILE) -> c_int; pub fn fdopen(fd: c_int, mode: *c_char) -> *FILE; @@ -3005,12 +2994,11 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod fcntl { use libc::types::os::arch::c95::{c_char, c_int}; use libc::types::os::arch::posix88::mode_t; - extern { + extern "cdecl" { pub fn open(path: *c_char, oflag: c_int, mode: c_int) -> c_int; pub fn creat(path: *c_char, mode: mode_t) -> c_int; @@ -3019,7 +3007,6 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod dirent { use libc::types::common::posix88::{DIR, dirent_t}; use libc::types::os::arch::c95::{c_char, c_int, c_long}; @@ -3039,12 +3026,12 @@ pub mod funcs { rust_readdir(dirp) } - extern { + extern "cdecl" { fn rust_opendir(dirname: *c_char) -> *DIR; fn rust_readdir(dirp: *DIR) -> *dirent_t; } - extern { + extern "cdecl" { pub fn closedir(dirp: *DIR) -> c_int; pub fn rewinddir(dirp: *DIR); pub fn seekdir(dirp: *DIR, loc: c_long); @@ -3053,7 +3040,6 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod unistd { use libc::types::common::c95::c_void; use libc::types::os::arch::c95::{c_char, c_int, c_long, c_uint}; @@ -3061,7 +3047,7 @@ pub mod funcs { use libc::types::os::arch::posix88::{gid_t, off_t, pid_t}; use libc::types::os::arch::posix88::{ssize_t, uid_t}; - extern { + extern "cdecl" { pub fn access(path: *c_char, amode: c_int) -> c_int; pub fn alarm(seconds: c_uint) -> c_uint; pub fn chdir(dir: *c_char) -> c_int; @@ -3115,24 +3101,22 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod signal { use libc::types::os::arch::c95::{c_int}; use libc::types::os::arch::posix88::{pid_t}; - extern { + extern "cdecl" { pub fn kill(pid: pid_t, sig: c_int) -> c_int; } } #[nolink] - #[abi = "cdecl"] pub mod mman { use libc::types::common::c95::{c_void}; use libc::types::os::arch::c95::{size_t, c_int, c_char}; use libc::types::os::arch::posix88::{mode_t, off_t}; - extern { + extern "cdecl" { pub fn mlock(addr: *c_void, len: size_t) -> c_int; pub fn munlock(addr: *c_void, len: size_t) -> c_int; pub fn mlockall(flags: c_int) -> c_int; @@ -3165,12 +3149,11 @@ pub mod funcs { #[cfg(target_os = "freebsd")] pub mod posix01 { #[nolink] - #[abi = "cdecl"] pub mod stat_ { use libc::types::os::arch::c95::{c_char, c_int}; use libc::types::os::arch::posix01::stat; - extern { + extern "cdecl" { #[cfg(target_os = "linux")] #[cfg(target_os = "freebsd")] #[cfg(target_os = "android")] @@ -3183,12 +3166,11 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod unistd { use libc::types::os::arch::c95::{c_char, c_int, size_t}; use libc::types::os::arch::posix88::{ssize_t}; - extern { + extern "cdecl" { pub fn readlink(path: *c_char, buf: *mut c_char, bufsz: size_t) @@ -3210,25 +3192,23 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod wait { use libc::types::os::arch::c95::{c_int}; use libc::types::os::arch::posix88::{pid_t}; - extern { + extern "cdecl" { pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; } } #[nolink] - #[abi = "cdecl"] pub mod glob { use libc::types::os::arch::c95::{c_char, c_int}; use libc::types::os::common::posix01::{glob_t}; use option::Option; - extern { + extern "cdecl" { pub fn glob(pattern: *c_char, flags: c_int, errfunc: Option int>, @@ -3238,12 +3218,11 @@ pub mod funcs { } #[nolink] - #[abi = "cdecl"] pub mod mman { use libc::types::common::c95::{c_void}; use libc::types::os::arch::c95::{c_int, size_t}; - extern { + extern "cdecl" { pub fn posix_madvise(addr: *c_void, len: size_t, advice: c_int) @@ -3286,8 +3265,7 @@ pub mod funcs { use libc::types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, size_t}; - #[abi = "cdecl"] - extern { + extern "cdecl" { pub fn sysctl(name: *c_int, namelen: c_uint, oldp: *mut c_void, @@ -3320,8 +3298,7 @@ pub mod funcs { use libc::types::common::c95::{c_void}; use libc::types::os::arch::c95::{c_uchar, c_int, size_t}; - #[abi = "cdecl"] - extern { + extern "cdecl" { pub fn getdtablesize() -> c_int; pub fn madvise(addr: *c_void, len: size_t, advice: c_int) -> c_int; @@ -3340,8 +3317,7 @@ pub mod funcs { pub mod extra { use libc::types::os::arch::c95::{c_char, c_int}; - #[abi = "cdecl"] - extern { + extern "cdecl" { pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32) -> c_int; } @@ -3373,7 +3349,6 @@ pub mod funcs { use libc::types::os::arch::extra::{HANDLE, LPHANDLE}; #[cfg(target_arch = "x86")] - #[abi = "stdcall"] extern "stdcall" { pub fn GetEnvironmentVariableW(n: LPCWSTR, v: LPWSTR, @@ -3587,9 +3562,8 @@ pub mod funcs { pub mod msvcrt { use libc::types::os::arch::c95::{c_int, c_long}; - #[abi = "cdecl"] #[nolink] - extern { + extern "cdecl" { #[link_name = "_commit"] pub fn commit(fd: c_int) -> c_int; diff --git a/src/libstd/num/cmath.rs b/src/libstd/num/cmath.rs index 38923c5bda45d..9a16a127378c8 100644 --- a/src/libstd/num/cmath.rs +++ b/src/libstd/num/cmath.rs @@ -18,8 +18,7 @@ pub mod c_double_utils { use libc::{c_double, c_int}; #[link_name = "m"] - #[abi = "cdecl"] - extern { + extern "cdecl" { // Alpabetically sorted by link_name pub fn acos(n: c_double) -> c_double; @@ -107,8 +106,7 @@ pub mod c_float_utils { use libc::{c_float, c_int}; #[link_name = "m"] - #[abi = "cdecl"] - extern { + extern "cdecl" { // Alpabetically sorted by link_name #[link_name="acosf"] diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 2b9727f6eb0e4..72f194ee50c06 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -237,11 +237,10 @@ impl Rand for @T { fn rand(rng: &mut R) -> @T { @rng.gen() } } -#[abi = "cdecl"] pub mod rustrt { use libc::size_t; - extern { + extern "cdecl" { pub fn rand_gen_seed(buf: *mut u8, sz: size_t); } } diff --git a/src/libstd/rt/thread_local_storage.rs b/src/libstd/rt/thread_local_storage.rs index b2c2c670b5558..4a8bb27f3e78d 100644 --- a/src/libstd/rt/thread_local_storage.rs +++ b/src/libstd/rt/thread_local_storage.rs @@ -87,7 +87,6 @@ pub unsafe fn get(key: Key) -> *mut c_void { } #[cfg(windows, target_arch = "x86")] -#[abi = "stdcall"] extern "stdcall" { fn TlsAlloc() -> DWORD; fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL; diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 362eab17fe70a..ae2220b85b67f 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -643,8 +643,7 @@ fn spawn_process_os(prog: &str, args: &[~str], use libc::funcs::bsd44::getdtablesize; mod rustrt { - #[abi = "cdecl"] - extern { + extern "cdecl" { pub fn rust_unset_sigprocmask(); } } diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs index 349739a5ea63d..58f7d23a19aff 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/unstable/intrinsics.rs @@ -171,7 +171,6 @@ pub trait TyVisitor { fn visit_closure_ptr(&mut self, ck: uint) -> bool; } -#[abi = "rust-intrinsic"] extern "rust-intrinsic" { /// Atomic compare and exchange, sequentially consistent. diff --git a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs index 3c73bd1b7f20e..987648ca6f2e7 100644 --- a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs +++ b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[abi = "cdecl"]; #[link_name = "rustrt"]; #[link(name = "anonexternmod", vers = "0.1")]; @@ -17,6 +16,6 @@ use std::libc; -extern { +extern "cdecl" { pub fn rust_get_test_int() -> libc::intptr_t; } diff --git a/src/test/auxiliary/cci_intrinsic.rs b/src/test/auxiliary/cci_intrinsic.rs index ebcb1e7fef9d0..9e69715d1cb21 100644 --- a/src/test/auxiliary/cci_intrinsic.rs +++ b/src/test/auxiliary/cci_intrinsic.rs @@ -9,7 +9,6 @@ // except according to those terms. pub mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int; pub fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int; diff --git a/src/test/compile-fail/foreign-unsafe-fn-called.rs b/src/test/compile-fail/foreign-unsafe-fn-called.rs index 6c74c860a4b1d..f6dca262d4c12 100644 --- a/src/test/compile-fail/foreign-unsafe-fn-called.rs +++ b/src/test/compile-fail/foreign-unsafe-fn-called.rs @@ -11,8 +11,7 @@ mod test { - #[abi = "cdecl"] - extern { + extern "cdecl" { pub fn free(); } } diff --git a/src/test/run-pass/anon-extern-mod.rs b/src/test/run-pass/anon-extern-mod.rs index ed9caa1f65e2f..ef951de6c4df5 100644 --- a/src/test/run-pass/anon-extern-mod.rs +++ b/src/test/run-pass/anon-extern-mod.rs @@ -10,9 +10,8 @@ use std::libc; -#[abi = "cdecl"] #[link_name = "rustrt"] -extern { +extern "cdecl" { fn rust_get_test_int() -> libc::intptr_t; } diff --git a/src/test/run-pass/c-stack-as-value.rs b/src/test/run-pass/c-stack-as-value.rs index ac7b221cff81c..9a38702efbd58 100644 --- a/src/test/run-pass/c-stack-as-value.rs +++ b/src/test/run-pass/c-stack-as-value.rs @@ -11,8 +11,7 @@ mod rustrt { use std::libc; - #[abi = "cdecl"] - extern { + extern "cdecl" { pub fn rust_get_test_int() -> libc::intptr_t; } } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index f140c4621aa27..7d7f0fc23fec9 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -11,9 +11,8 @@ mod libc { use std::libc::{c_char, c_long, c_longlong}; - #[abi = "cdecl"] #[nolink] - extern { + extern "cdecl" { pub fn atol(x: *c_char) -> c_long; pub fn atoll(x: *c_char) -> c_longlong; } diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index 00be4cd26f43a..dc10a0bbd7799 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -21,15 +21,13 @@ static b: bool = true; mod rustrt { #[cfg(bogus)] - #[abi = "cdecl"] - extern { + extern "cdecl" { // This symbol doesn't exist and would be a link error if this // module was translated pub fn bogus(); } - #[abi = "cdecl"] - extern {} + extern "cdecl" {} } #[cfg(bogus)] @@ -109,8 +107,7 @@ fn test_in_fn_ctxt() { mod test_foreign_items { pub mod rustrt { - #[abi = "cdecl"] - extern { + extern "cdecl" { #[cfg(bogus)] pub fn rust_get_stdin() -> ~str; pub fn rust_get_stdin() -> ~str; diff --git a/src/test/run-pass/foreign-dupe.rs b/src/test/run-pass/foreign-dupe.rs index 3ff1ebb57322c..bd2274004b189 100644 --- a/src/test/run-pass/foreign-dupe.rs +++ b/src/test/run-pass/foreign-dupe.rs @@ -14,9 +14,8 @@ mod rustrt1 { use std::libc; - #[abi = "cdecl"] #[link_name = "rustrt"] - extern { + extern "cdecl" { fn rust_get_test_int() -> libc::intptr_t; } } @@ -24,9 +23,8 @@ mod rustrt1 { mod rustrt2 { use std::libc; - #[abi = "cdecl"] #[link_name = "rustrt"] - extern { + extern "cdecl" { fn rust_get_test_int() -> libc::intptr_t; } } diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index 57b59e4445e77..d037feab452db 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -14,8 +14,7 @@ mod libc { use std::libc::{c_char, size_t}; #[nolink] - #[abi = "cdecl"] - extern { + extern "cdecl" { #[link_name = "strlen"] pub fn my_strlen(str: *c_char) -> size_t; } diff --git a/src/test/run-pass/foreign2.rs b/src/test/run-pass/foreign2.rs index 2cc7e27077284..654b3b7d43aaa 100644 --- a/src/test/run-pass/foreign2.rs +++ b/src/test/run-pass/foreign2.rs @@ -9,31 +9,27 @@ // except according to those terms. mod bar { - #[abi = "cdecl"] #[nolink] - extern {} + extern "cdecl" {} } mod zed { - #[abi = "cdecl"] #[nolink] - extern {} + extern "cdecl" {} } mod libc { use std::libc::{c_int, c_void, size_t, ssize_t}; - #[abi = "cdecl"] #[nolink] - extern { + extern "cdecl" { pub fn write(fd: c_int, buf: *c_void, count: size_t) -> ssize_t; } } mod baz { - #[abi = "cdecl"] #[nolink] - extern {} + extern "cdecl" {} } pub fn main() { } diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs index 90d4bd1e7aeca..051f92b165108 100644 --- a/src/test/run-pass/intrinsic-alignment.rs +++ b/src/test/run-pass/intrinsic-alignment.rs @@ -11,7 +11,6 @@ // xfail-fast Does not work with main in a submodule mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { pub fn pref_align_of() -> uint; pub fn min_align_of() -> uint; diff --git a/src/test/run-pass/intrinsic-atomics.rs b/src/test/run-pass/intrinsic-atomics.rs index f1354cbb20f5d..2ec91ee440b86 100644 --- a/src/test/run-pass/intrinsic-atomics.rs +++ b/src/test/run-pass/intrinsic-atomics.rs @@ -9,7 +9,6 @@ // except according to those terms. mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int; pub fn atomic_cxchg_acq(dst: &mut int, old: int, src: int) -> int; diff --git a/src/test/run-pass/intrinsic-frame-address.rs b/src/test/run-pass/intrinsic-frame-address.rs index 452104ec4a2aa..63635c7addfa0 100644 --- a/src/test/run-pass/intrinsic-frame-address.rs +++ b/src/test/run-pass/intrinsic-frame-address.rs @@ -11,7 +11,6 @@ // xfail-fast mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { pub fn frame_address(f: &once fn(*u8)); } diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs index 90f352c845b5b..f328c48447810 100644 --- a/src/test/run-pass/intrinsic-move-val.rs +++ b/src/test/run-pass/intrinsic-move-val.rs @@ -9,7 +9,6 @@ // except according to those terms. mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { pub fn move_val_init(dst: &mut T, src: T); pub fn move_val(dst: &mut T, src: T); diff --git a/src/test/run-pass/intrinsic-uninit.rs b/src/test/run-pass/intrinsic-uninit.rs index 993e277719765..1a4fd40fc68af 100644 --- a/src/test/run-pass/intrinsic-uninit.rs +++ b/src/test/run-pass/intrinsic-uninit.rs @@ -9,7 +9,6 @@ // except according to those terms. mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { fn uninit() -> T; } diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs index 4b17a95cf661d..cd28d5921fb64 100644 --- a/src/test/run-pass/intrinsics-integer.rs +++ b/src/test/run-pass/intrinsics-integer.rs @@ -13,7 +13,6 @@ extern mod extra; mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { fn ctpop8(x: i8) -> i8; fn ctpop16(x: i16) -> i16; diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index 62a01613c2065..ab1e1e8b5a8f0 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -11,7 +11,6 @@ // except according to those terms. mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { pub fn sqrtf32(x: f32) -> f32; pub fn sqrtf64(x: f64) -> f64; diff --git a/src/test/run-pass/issue-2214.rs b/src/test/run-pass/issue-2214.rs index 1bb8a0008760b..298c4e7454d5f 100644 --- a/src/test/run-pass/issue-2214.rs +++ b/src/test/run-pass/issue-2214.rs @@ -30,8 +30,7 @@ mod m { use std::libc::{c_double, c_int}; #[link_name = "m"] - #[abi = "cdecl"] - extern { + extern "cdecl" { #[cfg(unix)] #[link_name="lgamma_r"] pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double; diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index 29c1c63066047..ec9d574953376 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -39,8 +39,7 @@ mod test_single_attr_outer { pub mod rustrt { #[attr = "val"] - #[abi = "cdecl"] - extern {} + extern "cdecl" {} } } @@ -60,8 +59,7 @@ mod test_multi_attr_outer { pub mod rustrt { #[attr1 = "val"] #[attr2 = "val"] - #[abi = "cdecl"] - extern {} + extern "cdecl" {} } #[attr1 = "val"] @@ -83,8 +81,7 @@ mod test_stmt_single_attr_outer { mod rustrt { #[attr = "val"] - #[abi = "cdecl"] - extern { + extern "cdecl" { } } } @@ -110,8 +107,7 @@ mod test_stmt_multi_attr_outer { pub mod rustrt { #[attr1 = "val"] #[attr2 = "val"] - #[abi = "cdecl"] - extern { + extern "cdecl" { } } */ @@ -169,8 +165,7 @@ mod test_foreign_items { pub mod rustrt { use std::libc; - #[abi = "cdecl"] - extern { + extern "cdecl" { #[attr]; #[attr] diff --git a/src/test/run-pass/morestack-address.rs b/src/test/run-pass/morestack-address.rs index ef6bb4e93b2da..ebeb8927f6ed0 100644 --- a/src/test/run-pass/morestack-address.rs +++ b/src/test/run-pass/morestack-address.rs @@ -10,7 +10,6 @@ mod rusti { #[nolink] - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { pub fn morestack_addr() -> *(); } diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index 6c4d9915d85f9..49602a40e6519 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -15,7 +15,6 @@ use std::sys; mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { pub fn pref_align_of() -> uint; pub fn min_align_of() -> uint; diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index c116353e9c917..4b8936d92acf1 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -15,7 +15,6 @@ use std::sys; mod rusti { - #[abi = "rust-intrinsic"] extern "rust-intrinsic" { pub fn pref_align_of() -> uint; pub fn min_align_of() -> uint; diff --git a/src/test/run-pass/x86stdcall2.rs b/src/test/run-pass/x86stdcall2.rs index 3722dccf94b94..b16218a59f982 100644 --- a/src/test/run-pass/x86stdcall2.rs +++ b/src/test/run-pass/x86stdcall2.rs @@ -18,7 +18,6 @@ pub type BOOL = u8; mod kernel32 { use super::{HANDLE, DWORD, SIZE_T, LPVOID, BOOL}; - #[abi = "stdcall"] extern "stdcall" { pub fn GetProcessHeap() -> HANDLE; pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T)