Skip to content

Commit 3c2650b

Browse files
committed
auto merge of #12328 : nick29581/rust/abi, r=alexcrichton
2 parents 7cc6b5e + 317a253 commit 3c2650b

19 files changed

+53
-30
lines changed

src/librustc/middle/typeck/infer/combine.rs

+1
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ pub fn super_tys<C:Combine>(this: &C, a: ty::t, b: ty::t) -> cres<ty::t> {
500500
(&ty::ty_trait(a_id, ref a_substs, a_store, a_mutbl, a_bounds),
501501
&ty::ty_trait(b_id, ref b_substs, b_store, b_mutbl, b_bounds))
502502
if a_id == b_id && a_mutbl == b_mutbl => {
503+
debug!("Trying to match traits {:?} and {:?}", a, b);
503504
let substs = if_ok!(this.substs(a_id, a_substs, b_substs));
504505
let s = if_ok!(this.trait_stores(ty::terr_trait, a_store, b_store));
505506
let bounds = if_ok!(this.bounds(a_bounds, b_bounds));

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub mod test;
5353
pub static SCHEMA_VERSION: &'static str = "0.8.1";
5454

5555
type Pass = (&'static str, // name
56-
extern fn(clean::Crate) -> plugins::PluginResult, // fn
56+
fn(clean::Crate) -> plugins::PluginResult, // fn
5757
&'static str); // description
5858

5959
static PASSES: &'static [Pass] = &[

src/librustdoc/plugins.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use dl = std::unstable::dynamic_lib;
1515

1616
pub type PluginJson = Option<(~str, json::Json)>;
1717
pub type PluginResult = (clean::Crate, PluginJson);
18-
pub type PluginCallback = extern fn (clean::Crate) -> PluginResult;
18+
pub type PluginCallback = fn (clean::Crate) -> PluginResult;
1919

2020
/// Manages loading and running of plugins
2121
pub struct PluginManager {

src/libsyntax/parse/parser.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,12 @@ impl Parser {
862862
863863
*/
864864

865-
let opt_abis = if self.eat_keyword(keywords::Extern) {
866-
self.parse_opt_abis()
867-
} else { None };
865+
let abis = if self.eat_keyword(keywords::Extern) {
866+
self.parse_opt_abis().unwrap_or(AbiSet::C())
867+
} else {
868+
AbiSet::Rust()
869+
};
868870

869-
let abis = opt_abis.unwrap_or(AbiSet::Rust());
870871
let purity = self.parse_unsafety();
871872
self.expect_keyword(keywords::Fn);
872873
let (decl, lifetimes) = self.parse_ty_fn_decl(true);

src/libtest/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ pub trait TDynBenchFn {
106106
// may need to come up with a more clever definition of test in order
107107
// to support isolation of tests into tasks.
108108
pub enum TestFn {
109-
StaticTestFn(extern fn()),
110-
StaticBenchFn(extern fn(&mut BenchHarness)),
109+
StaticTestFn(fn()),
110+
StaticBenchFn(fn(&mut BenchHarness)),
111111
StaticMetricFn(proc(&mut MetricMap)),
112112
DynTestFn(proc()),
113113
DynMetricFn(proc(&mut MetricMap)),

src/test/auxiliary/static-function-pointer-aux.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
pub fn f(x: int) -> int { -x }
1414

15-
pub static F: extern fn(int) -> int = f;
16-
pub static mut MutF: extern fn(int) -> int = f;
15+
pub static F: fn(int) -> int = f;
16+
pub static mut MutF: fn(int) -> int = f;

src/test/compile-fail/block-coerce-no-2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// other tycons.
1313

1414
fn main() {
15-
fn f(f: extern fn(extern fn(extern fn()))) {
15+
fn f(f: fn(fn(fn()))) {
1616
}
1717

18-
fn g(f: extern fn(||)) {
18+
fn g(f: fn(||)) {
1919
}
2020

2121
f(g);

src/test/compile-fail/borrowck-autoref-3261.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
enum Either<T, U> { Left(T), Right(U) }
1212

13-
struct X(Either<(uint,uint),extern fn()>);
13+
struct X(Either<(uint,uint), fn()>);
1414

1515
impl X {
16-
pub fn with(&self, blk: |x: &Either<(uint,uint),extern fn()>|) {
16+
pub fn with(&self, blk: |x: &Either<(uint,uint), fn()>|) {
1717
let X(ref e) = *self;
1818
blk(e)
1919
}

src/test/run-pass/const-vec-of-fns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
fn f() { }
19-
static bare_fns: &'static [extern fn()] = &[f, f];
19+
static bare_fns: &'static [fn()] = &[f, f];
2020
struct S<'a>('a ||);
2121
static closures: &'static [S<'static>] = &[S(f), S(f)];
2222

src/test/run-pass/fn-abi.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Ensure that declarations and types which use `extern fn` both have the same
12+
// ABI (#9309).
13+
14+
extern {
15+
fn printf();
16+
}
17+
18+
pub fn main() {
19+
// Will only type check if the type of _p and the decl of printf use the same ABI
20+
let _p: extern unsafe fn() = printf;
21+
}

src/test/run-pass/fn-bare-assign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn f(i: int, called: &mut bool) {
1313
*called = true;
1414
}
1515

16-
fn g(f: extern fn(int, v: &mut bool), called: &mut bool) {
16+
fn g(f: fn(int, v: &mut bool), called: &mut bool) {
1717
f(10, called);
1818
}
1919

src/test/run-pass/fn-bare-spawn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// This is what the signature to spawn should look like with bare functions
1212

13-
fn spawn<T:Send>(val: T, f: extern fn(T)) {
13+
fn spawn<T:Send>(val: T, f: fn(T)) {
1414
f(val);
1515
}
1616

src/test/run-pass/fn-lval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313

14-
fn foo(_f: extern fn(int) -> int) { }
14+
fn foo(_f: fn(int) -> int) { }
1515

1616
fn id(x: int) -> int { return x; }
1717

src/test/run-pass/fun-indirect-call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
fn f() -> int { return 42; }
1515

1616
pub fn main() {
17-
let g: extern fn() -> int = f;
17+
let g: fn() -> int = f;
1818
let i: int = g();
1919
assert_eq!(i, 42);
2020
}

src/test/run-pass/generic-temporary.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ fn mk() -> int { return 1; }
1414

1515
fn chk(a: int) { info!("{}", a); assert!((a == 1)); }
1616

17-
fn apply<T>(produce: extern fn() -> T,
18-
consume: extern fn(T)) {
17+
fn apply<T>(produce: fn() -> T,
18+
consume: fn(T)) {
1919
consume(produce());
2020
}
2121

2222
pub fn main() {
23-
let produce: extern fn() -> int = mk;
24-
let consume: extern fn(v: int) = chk;
23+
let produce: fn() -> int = mk;
24+
let consume: fn(v: int) = chk;
2525
apply::<int>(produce, consume);
2626
}

src/test/run-pass/newtype.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
struct mytype(Mytype);
1212

13-
struct Mytype {compute: extern fn(mytype) -> int, val: int}
13+
struct Mytype {compute: fn(mytype) -> int, val: int}
1414

1515
fn compute(i: mytype) -> int {
1616
let mytype(m) = i;

src/test/run-pass/static-function-pointer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
fn f(x: int) -> int { x }
1212
fn g(x: int) -> int { 2 * x }
1313

14-
static F: extern fn(int) -> int = f;
15-
static mut G: extern fn(int) -> int = f;
14+
static F: fn(int) -> int = f;
15+
static mut G: fn(int) -> int = f;
1616

1717
pub fn main() {
1818
assert_eq!(F(42), 42);

src/test/run-pass/tail-cps.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ fn checktrue(rs: bool) -> bool { assert!((rs)); return true; }
1515

1616
pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); }
1717

18-
fn evenk(n: int, k: extern fn(bool) -> bool) -> bool {
18+
fn evenk(n: int, k: fn(bool) -> bool) -> bool {
1919
info!("evenk");
2020
info!("{:?}", n);
2121
if n == 0 { return k(true); } else { return oddk(n - 1, k); }
2222
}
2323

24-
fn oddk(n: int, k: extern fn(bool) -> bool) -> bool {
24+
fn oddk(n: int, k: fn(bool) -> bool) -> bool {
2525
info!("oddk");
2626
info!("{:?}", n);
2727
if n == 0 { return k(false); } else { return evenk(n - 1, k); }

src/test/run-pass/tuple-struct-constructor-pointer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ struct Foo(int);
1414
struct Bar(int, int);
1515

1616
pub fn main() {
17-
let f: extern fn(int) -> Foo = Foo;
18-
let g: extern fn(int, int) -> Bar = Bar;
17+
let f: fn(int) -> Foo = Foo;
18+
let g: fn(int, int) -> Bar = Bar;
1919
assert_eq!(f(42), Foo(42));
2020
assert_eq!(g(4, 7), Bar(4, 7));
2121
}

0 commit comments

Comments
 (0)