Skip to content

Commit 317a253

Browse files
committed
All uses of extern fn should mean extern "C" fn. Closes #9309.
1 parent cbed332 commit 317a253

19 files changed

+53
-30
lines changed

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 21 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)