(&ty::ty_trait(a_id, ref a_substs, a_store, a_mutbl, a_bounds),
&ty::ty_trait(b_id, ref b_substs, b_store, b_mutbl, b_bounds))
if a_id == b_id && a_mutbl == b_mutbl => {
+ debug!("Trying to match traits {:?} and {:?}", a, b);
let substs = if_ok!(this.substs(a_id, a_substs, b_substs));
let s = if_ok!(this.trait_stores(ty::terr_trait, a_store, b_store));
let bounds = if_ok!(this.bounds(a_bounds, b_bounds));
pub static SCHEMA_VERSION: &'static str = "0.8.1";
type Pass = (&'static str, // name
- extern fn(clean::Crate) -> plugins::PluginResult, // fn
+ fn(clean::Crate) -> plugins::PluginResult, // fn
&'static str); // description
static PASSES: &'static [Pass] = &[
pub type PluginJson = Option<(~str, json::Json)>;
pub type PluginResult = (clean::Crate, PluginJson);
-pub type PluginCallback = extern fn (clean::Crate) -> PluginResult;
+pub type PluginCallback = fn (clean::Crate) -> PluginResult;
/// Manages loading and running of plugins
pub struct PluginManager {
*/
- let opt_abis = if self.eat_keyword(keywords::Extern) {
- self.parse_opt_abis()
- } else { None };
+ let abis = if self.eat_keyword(keywords::Extern) {
+ self.parse_opt_abis().unwrap_or(AbiSet::C())
+ } else {
+ AbiSet::Rust()
+ };
- let abis = opt_abis.unwrap_or(AbiSet::Rust());
let purity = self.parse_unsafety();
self.expect_keyword(keywords::Fn);
let (decl, lifetimes) = self.parse_ty_fn_decl(true);
// may need to come up with a more clever definition of test in order
// to support isolation of tests into tasks.
pub enum TestFn {
- StaticTestFn(extern fn()),
- StaticBenchFn(extern fn(&mut BenchHarness)),
+ StaticTestFn(fn()),
+ StaticBenchFn(fn(&mut BenchHarness)),
StaticMetricFn(proc(&mut MetricMap)),
DynTestFn(proc()),
DynMetricFn(proc(&mut MetricMap)),
pub fn f(x: int) -> int { -x }
-pub static F: extern fn(int) -> int = f;
-pub static mut MutF: extern fn(int) -> int = f;
+pub static F: fn(int) -> int = f;
+pub static mut MutF: fn(int) -> int = f;
// other tycons.
fn main() {
- fn f(f: extern fn(extern fn(extern fn()))) {
+ fn f(f: fn(fn(fn()))) {
}
- fn g(f: extern fn(||)) {
+ fn g(f: fn(||)) {
}
f(g);
enum Either<T, U> { Left(T), Right(U) }
-struct X(Either<(uint,uint),extern fn()>);
+struct X(Either<(uint,uint), fn()>);
impl X {
- pub fn with(&self, blk: |x: &Either<(uint,uint),extern fn()>|) {
+ pub fn with(&self, blk: |x: &Either<(uint,uint), fn()>|) {
let X(ref e) = *self;
blk(e)
}
*/
fn f() { }
-static bare_fns: &'static [extern fn()] = &[f, f];
+static bare_fns: &'static [fn()] = &[f, f];
struct S<'a>('a ||);
static closures: &'static [S<'static>] = &[S(f), S(f)];
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Ensure that declarations and types which use `extern fn` both have the same
+// ABI (#9309).
+
+extern {
+ fn printf();
+}
+
+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;
+}
*called = true;
}
-fn g(f: extern fn(int, v: &mut bool), called: &mut bool) {
+fn g(f: fn(int, v: &mut bool), called: &mut bool) {
f(10, called);
}
// This is what the signature to spawn should look like with bare functions
-fn spawn<T:Send>(val: T, f: extern fn(T)) {
+fn spawn<T:Send>(val: T, f: fn(T)) {
f(val);
}
-fn foo(_f: extern fn(int) -> int) { }
+fn foo(_f: fn(int) -> int) { }
fn id(x: int) -> int { return x; }
fn f() -> int { return 42; }
pub fn main() {
- let g: extern fn() -> int = f;
+ let g: fn() -> int = f;
let i: int = g();
assert_eq!(i, 42);
}
fn chk(a: int) { info!("{}", a); assert!((a == 1)); }
-fn apply<T>(produce: extern fn() -> T,
- consume: extern fn(T)) {
+fn apply<T>(produce: fn() -> T,
+ consume: fn(T)) {
consume(produce());
}
pub fn main() {
- let produce: extern fn() -> int = mk;
- let consume: extern fn(v: int) = chk;
+ let produce: fn() -> int = mk;
+ let consume: fn(v: int) = chk;
apply::<int>(produce, consume);
}
struct mytype(Mytype);
-struct Mytype {compute: extern fn(mytype) -> int, val: int}
+struct Mytype {compute: fn(mytype) -> int, val: int}
fn compute(i: mytype) -> int {
let mytype(m) = i;
fn f(x: int) -> int { x }
fn g(x: int) -> int { 2 * x }
-static F: extern fn(int) -> int = f;
-static mut G: extern fn(int) -> int = f;
+static F: fn(int) -> int = f;
+static mut G: fn(int) -> int = f;
pub fn main() {
assert_eq!(F(42), 42);
pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); }
-fn evenk(n: int, k: extern fn(bool) -> bool) -> bool {
+fn evenk(n: int, k: fn(bool) -> bool) -> bool {
info!("evenk");
info!("{:?}", n);
if n == 0 { return k(true); } else { return oddk(n - 1, k); }
}
-fn oddk(n: int, k: extern fn(bool) -> bool) -> bool {
+fn oddk(n: int, k: fn(bool) -> bool) -> bool {
info!("oddk");
info!("{:?}", n);
if n == 0 { return k(false); } else { return evenk(n - 1, k); }
struct Bar(int, int);
pub fn main() {
- let f: extern fn(int) -> Foo = Foo;
- let g: extern fn(int, int) -> Bar = Bar;
+ let f: fn(int) -> Foo = Foo;
+ let g: fn(int, int) -> Bar = Bar;
assert_eq!(f(42), Foo(42));
assert_eq!(g(4, 7), Bar(4, 7));
}