Update code to account for extern ABI requirement

This commit is contained in:
Mark Rousskov 2020-09-01 17:28:11 -04:00
parent 920b5ee722
commit 4614671cae
78 changed files with 155 additions and 166 deletions

View File

@ -6,7 +6,7 @@ Erroneous code example:
#![feature(unwind_attributes)]
#[unwind()] // error: expected one argument
pub extern fn something() {}
pub extern "C" fn something() {}
fn main() {}
```

View File

@ -401,7 +401,7 @@ mod enum_keyword {}
///
/// ```rust
/// #[no_mangle]
/// pub extern fn callable_from_c(x: i32) -> bool {
/// pub extern "C" fn callable_from_c(x: i32) -> bool {
/// x % 3 == 0
/// }
/// ```

View File

@ -28,7 +28,7 @@ use crate::sync::atomic::{self, AtomicUsize, Ordering};
macro_rules! weak {
(fn $name:ident($($t:ty),*) -> $ret:ty) => (
static $name: crate::sys::weak::Weak<unsafe extern fn($($t),*) -> $ret> =
static $name: crate::sys::weak::Weak<unsafe extern "C" fn($($t),*) -> $ret> =
crate::sys::weak::Weak::new(concat!(stringify!($name), '\0'));
)
}

View File

@ -26,17 +26,17 @@ pub mod xyz {
// CHECK: !DISubprogram(name: "e",
// CHECK: linkageName:
// CHECK-SAME: line: 29,
pub extern fn e() {}
pub extern "C" fn e() {}
// CHECK: !DISubprogram(name: "f",
// CHECK-NOT: linkageName:
// CHECK-SAME: line: 35,
#[no_mangle]
pub extern fn f() {}
pub extern "C" fn f() {}
// CHECK: !DISubprogram(name: "g",
// CHECK-NOT: linkageName:
// CHECK-SAME: line: 41,
#[export_name = "g"]
pub extern fn g() {}
pub extern "C" fn g() {}
}

View File

@ -13,19 +13,19 @@ mod private {
// CHECK: void @a()
#[no_mangle]
pub extern fn a() {}
pub extern "C" fn a() {}
// CHECK: void @b()
#[export_name = "b"]
extern fn b() {}
extern "C" fn b() {}
// CHECK: void @c()
#[export_name = "c"]
#[inline]
extern fn c() {}
extern "C" fn c() {}
// CHECK: void @d()
#[export_name = "d"]
#[inline(always)]
extern fn d() {}
extern "C" fn d() {}
}

View File

@ -6,4 +6,4 @@ pub struct Foo(u64);
// CHECK: define {{.*}} @foo(
#[no_mangle]
pub extern fn foo(_: Foo) -> Foo { loop {} }
pub extern "C" fn foo(_: Foo) -> Foo { loop {} }

View File

@ -36,19 +36,19 @@ pub enum TeBigS {
// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS:.*]], %BigS* [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]])
#[no_mangle]
pub extern fn test_BigS(_: BigS) -> BigS { loop {} }
pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} }
// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS]], %TsBigS* [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]])
#[no_mangle]
pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS]], %TuBigS* [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]])
#[no_mangle]
pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS]], %"TeBigS::Variant"* [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]])
#[no_mangle]
pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
#[derive(Clone, Copy)]
@ -72,16 +72,16 @@ pub enum TeBigU {
// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], %BigU* [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]])
#[no_mangle]
pub extern fn test_BigU(_: BigU) -> BigU { loop {} }
pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} }
// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS:.*]], %TsBigU* [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]])
#[no_mangle]
pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS]], %TuBigU* [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]])
#[no_mangle]
pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS]], %"TeBigU::Variant"* [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]])
#[no_mangle]
pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }
pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }

View File

@ -19,21 +19,21 @@ pub struct F32(f32);
// CHECK: define float @test_F32(float %_1)
#[no_mangle]
pub extern fn test_F32(_: F32) -> F32 { loop {} }
pub extern "C" fn test_F32(_: F32) -> F32 { loop {} }
#[repr(transparent)]
pub struct Ptr(*mut u8);
// CHECK: define i8* @test_Ptr(i8* %_1)
#[no_mangle]
pub extern fn test_Ptr(_: Ptr) -> Ptr { loop {} }
pub extern "C" fn test_Ptr(_: Ptr) -> Ptr { loop {} }
#[repr(transparent)]
pub struct WithZst(u64, Zst1);
// CHECK: define i64 @test_WithZst(i64 %_1)
#[no_mangle]
pub extern fn test_WithZst(_: WithZst) -> WithZst { loop {} }
pub extern "C" fn test_WithZst(_: WithZst) -> WithZst { loop {} }
#[repr(transparent)]
pub struct WithZeroSizedArray(*const f32, [i8; 0]);
@ -41,14 +41,14 @@ pub struct WithZeroSizedArray(*const f32, [i8; 0]);
// Apparently we use i32* when newtype-unwrapping f32 pointers. Whatever.
// CHECK: define i32* @test_WithZeroSizedArray(i32* %_1)
#[no_mangle]
pub extern fn test_WithZeroSizedArray(_: WithZeroSizedArray) -> WithZeroSizedArray { loop {} }
pub extern "C" fn test_WithZeroSizedArray(_: WithZeroSizedArray) -> WithZeroSizedArray { loop {} }
#[repr(transparent)]
pub struct Generic<T>(T);
// CHECK: define double @test_Generic(double %_1)
#[no_mangle]
pub extern fn test_Generic(_: Generic<f64>) -> Generic<f64> { loop {} }
pub extern "C" fn test_Generic(_: Generic<f64>) -> Generic<f64> { loop {} }
#[repr(transparent)]
pub struct GenericPlusZst<T>(T, Zst2);
@ -58,14 +58,14 @@ pub enum Bool { True, False, FileNotFound }
// CHECK: define{{( zeroext)?}} i8 @test_Gpz(i8{{( zeroext)?}} %_1)
#[no_mangle]
pub extern fn test_Gpz(_: GenericPlusZst<Bool>) -> GenericPlusZst<Bool> { loop {} }
pub extern "C" fn test_Gpz(_: GenericPlusZst<Bool>) -> GenericPlusZst<Bool> { loop {} }
#[repr(transparent)]
pub struct LifetimePhantom<'a, T: 'a>(*const T, PhantomData<&'a T>);
// CHECK: define i16* @test_LifetimePhantom(i16* %_1)
#[no_mangle]
pub extern fn test_LifetimePhantom(_: LifetimePhantom<i16>) -> LifetimePhantom<i16> { loop {} }
pub extern "C" fn test_LifetimePhantom(_: LifetimePhantom<i16>) -> LifetimePhantom<i16> { loop {} }
// This works despite current alignment resrictions because PhantomData is always align(1)
#[repr(transparent)]
@ -75,28 +75,28 @@ pub struct Px;
// CHECK: define float @test_UnitPhantom(float %_1)
#[no_mangle]
pub extern fn test_UnitPhantom(_: UnitPhantom<f32, Px>) -> UnitPhantom<f32, Px> { loop {} }
pub extern "C" fn test_UnitPhantom(_: UnitPhantom<f32, Px>) -> UnitPhantom<f32, Px> { loop {} }
#[repr(transparent)]
pub struct TwoZsts(Zst1, i8, Zst2);
// CHECK: define{{( signext)?}} i8 @test_TwoZsts(i8{{( signext)?}} %_1)
#[no_mangle]
pub extern fn test_TwoZsts(_: TwoZsts) -> TwoZsts { loop {} }
pub extern "C" fn test_TwoZsts(_: TwoZsts) -> TwoZsts { loop {} }
#[repr(transparent)]
pub struct Nested1(Zst2, Generic<f64>);
// CHECK: define double @test_Nested1(double %_1)
#[no_mangle]
pub extern fn test_Nested1(_: Nested1) -> Nested1 { loop {} }
pub extern "C" fn test_Nested1(_: Nested1) -> Nested1 { loop {} }
#[repr(transparent)]
pub struct Nested2(Nested1, Zst1);
// CHECK: define double @test_Nested2(double %_1)
#[no_mangle]
pub extern fn test_Nested2(_: Nested2) -> Nested2 { loop {} }
pub extern "C" fn test_Nested2(_: Nested2) -> Nested2 { loop {} }
#[repr(simd)]
struct f32x4(f32, f32, f32, f32);
@ -106,7 +106,7 @@ pub struct Vector(f32x4);
// CHECK: define <4 x float> @test_Vector(<4 x float> %_1)
#[no_mangle]
pub extern fn test_Vector(_: Vector) -> Vector { loop {} }
pub extern "C" fn test_Vector(_: Vector) -> Vector { loop {} }
trait Mirror { type It: ?Sized; }
impl<T: ?Sized> Mirror for T { type It = Self; }
@ -116,7 +116,7 @@ pub struct StructWithProjection(<f32 as Mirror>::It);
// CHECK: define float @test_Projection(float %_1)
#[no_mangle]
pub extern fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} }
pub extern "C" fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} }
#[repr(transparent)]
pub enum EnumF32 {
@ -125,7 +125,7 @@ pub enum EnumF32 {
// CHECK: define float @test_EnumF32(float %_1)
#[no_mangle]
pub extern fn test_EnumF32(_: EnumF32) -> EnumF32 { loop {} }
pub extern "C" fn test_EnumF32(_: EnumF32) -> EnumF32 { loop {} }
#[repr(transparent)]
pub enum EnumF32WithZsts {
@ -134,7 +134,7 @@ pub enum EnumF32WithZsts {
// CHECK: define float @test_EnumF32WithZsts(float %_1)
#[no_mangle]
pub extern fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts { loop {} }
pub extern "C" fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts { loop {} }
#[repr(transparent)]
pub union UnionF32 {
@ -143,7 +143,7 @@ pub union UnionF32 {
// CHECK: define float @test_UnionF32(float %_1)
#[no_mangle]
pub extern fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} }
pub extern "C" fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} }
#[repr(transparent)]
pub union UnionF32WithZsts {
@ -154,7 +154,7 @@ pub union UnionF32WithZsts {
// CHECK: define float @test_UnionF32WithZsts(float %_1)
#[no_mangle]
pub extern fn test_UnionF32WithZsts(_: UnionF32WithZsts) -> UnionF32WithZsts { loop {} }
pub extern "C" fn test_UnionF32WithZsts(_: UnionF32WithZsts) -> UnionF32WithZsts { loop {} }
// All that remains to be tested are aggregates. They are tested in separate files called repr-

View File

@ -9,7 +9,7 @@
// CHECK-LABEL: define {{.*}} @exported() {{.*}} #0
#[no_mangle]
pub extern fn exported() {
pub extern "C" fn exported() {
not_exported();
}

View File

@ -11,7 +11,7 @@
// "C" ABI
// pub extern fn foo() {} // FIXME right now we don't abort-on-panic but add `nounwind` nevertheless
#[unwind(allowed)]
pub extern fn foo_allowed() {}
pub extern "C" fn foo_allowed() {}
// "Rust"
// (`extern "Rust"` could be removed as all `fn` get it implicitly; we leave it in for clarity.)

View File

@ -271,7 +271,7 @@ impl Foo {
impl Foo {
#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,fn_sig,typeck")]
#[rustc_clean(cfg="cfail3")]
pub extern fn make_method_extern(&self) { }
pub extern "C" fn make_method_extern(&self) { }
}

View File

@ -312,7 +312,7 @@ trait TraitAddExternModifier {
trait TraitAddExternModifier {
#[rustc_dirty(label="hir_owner", cfg="cfail2")]
#[rustc_clean(label="hir_owner", cfg="cfail3")]
extern fn method();
extern "C" fn method();
}

View File

@ -3,11 +3,11 @@
extern crate bar;
#[no_mangle]
pub extern fn foo() {
pub extern "C" fn foo() {
bar::bar();
}
#[no_mangle]
pub extern fn bar(a: u32, b: u32) -> u32 {
pub extern "C" fn bar(a: u32, b: u32) -> u32 {
a + b
}

View File

@ -1,6 +1,6 @@
#![crate_type = "cdylib"]
#[no_mangle]
pub extern fn foo() -> u32 {
pub extern "C" fn foo() -> u32 {
3
}

View File

@ -3,11 +3,11 @@
extern crate bar;
#[no_mangle]
pub extern fn foo() {
pub extern "C" fn foo() {
bar::bar();
}
#[no_mangle]
pub extern fn bar(a: u32, b: u32) -> u32 {
pub extern "C" fn bar(a: u32, b: u32) -> u32 {
a + b
}

View File

@ -3,6 +3,6 @@
extern crate upstream;
#[no_mangle]
pub extern fn bar() {
pub extern "C" fn bar() {
upstream::foo();
}

View File

@ -1,4 +1,4 @@
#[no_mangle]
pub extern fn args_check() {
pub extern "C" fn args_check() {
assert_ne!(std::env::args_os().count(), 0);
}

View File

@ -1,5 +1,5 @@
#[no_mangle]
pub extern fn foo() {}
pub extern "C" fn foo() {}
#[no_mangle]
pub static FOO_STATIC: u8 = 0;

View File

@ -1,5 +1,5 @@
#[no_mangle]
pub extern fn overflow() {
pub extern "C" fn overflow() {
let xs = [0, 1, 2, 3];
let _y = unsafe { *xs.as_ptr().offset(4) };
}

View File

@ -1,5 +1,5 @@
#[no_mangle]
pub extern fn overflow() {
pub extern "C" fn overflow() {
let xs = [0, 1, 2, 3];
let _y = unsafe { *xs.as_ptr().offset(4) };
}

View File

@ -1,5 +1,5 @@
#[no_mangle]
pub extern fn overflow() {
pub extern "C" fn overflow() {
let xs = [0, 1, 2, 3];
let _y = unsafe { *xs.as_ptr().offset(4) };
}

View File

@ -3,6 +3,6 @@
extern crate foo;
#[no_mangle]
pub extern fn bar() {
pub extern "C" fn bar() {
foo::foo();
}

View File

@ -6,6 +6,6 @@ extern crate bar;
static A: bar::A = bar::A;
#[no_mangle]
pub extern fn a(a: u32, b: u32) -> u32 {
pub extern "C" fn a(a: u32, b: u32) -> u32 {
a / b
}

View File

@ -2,7 +2,7 @@
// Test direct calls to extern fns.
extern fn f(x: usize) -> usize { x * 2 }
extern "C" fn f(x: usize) -> usize { x * 2 }
pub fn main() {
let x = f(22);

View File

@ -3,4 +3,4 @@
#![crate_type = "rlib"]
#[no_mangle]
pub extern fn foo() {}
pub extern "C" fn foo() {}

View File

@ -3,4 +3,4 @@
#![crate_type = "rlib"]
#[no_mangle]
pub extern fn foo() {}
pub extern "C" fn foo() {}

View File

@ -1,4 +1,4 @@
pub extern fn bar() {
pub extern "C" fn bar() {
}
pub const foopy: &'static str = "hi there";

View File

@ -1,5 +1,5 @@
pub struct VTable{
state:extern fn(),
state:extern "C" fn(),
}
impl VTable{
@ -11,4 +11,4 @@ impl VTable{
&VTable{state};
}
extern fn state() {}
extern "C" fn state() {}

View File

@ -7,7 +7,7 @@ struct TestStruct {
unsafe impl Sync for TestStruct {}
extern fn foo() {}
extern "C" fn foo() {}
const x: extern "C" fn() = foo;
static y: TestStruct = TestStruct { x: x as *const u8 };

View File

@ -4,16 +4,16 @@ extern "C" {
fn regular_in_block();
}
const extern fn bar() {
const extern "C" fn bar() {
unsafe {
regular_in_block();
//~^ ERROR: calls in constant functions
}
}
extern fn regular() {}
extern "C" fn regular() {}
const extern fn foo() {
const extern "C" fn foo() {
unsafe {
regular();
//~^ ERROR: calls in constant functions

View File

@ -1,10 +1,10 @@
#![feature(const_extern_fn)]
const extern fn unsize(x: &[u8; 3]) -> &[u8] { x }
const extern "C" fn unsize(x: &[u8; 3]) -> &[u8] { x }
const unsafe extern "C" fn closure() -> fn() { || {} }
//~^ ERROR function pointer
//~| ERROR function pointer cast
const unsafe extern fn use_float() { 1.0 + 1.0; }
const unsafe extern "C" fn use_float() { 1.0 + 1.0; }
//~^ ERROR floating point arithmetic
const extern "C" fn ptr_cast(val: *const u8) { val as usize; }
//~^ ERROR casting pointers to integers

View File

@ -17,10 +17,10 @@ LL | const unsafe extern "C" fn closure() -> fn() { || {} }
= help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable
error[E0658]: floating point arithmetic is not allowed in constant functions
--> $DIR/const-extern-fn-min-const-fn.rs:7:38
--> $DIR/const-extern-fn-min-const-fn.rs:7:42
|
LL | const unsafe extern fn use_float() { 1.0 + 1.0; }
| ^^^^^^^^^
LL | const unsafe extern "C" fn use_float() { 1.0 + 1.0; }
| ^^^^^^^^^
|
= note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information
= help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable

View File

@ -1,6 +1,6 @@
#![feature(const_extern_fn)]
const unsafe extern fn foo() -> usize { 5 }
const unsafe extern "C" fn foo() -> usize { 5 }
fn main() {
let a: [u8; foo()];

View File

@ -1,7 +1,7 @@
// run-pass
#![feature(const_extern_fn)]
const extern fn foo1(val: u8) -> u8 {
const extern "C" fn foo1(val: u8) -> u8 {
val + 1
}
@ -9,7 +9,7 @@ const extern "C" fn foo2(val: u8) -> u8 {
val + 1
}
const unsafe extern fn bar1(val: bool) -> bool {
const unsafe extern "C" fn bar1(val: bool) -> bool {
!val
}
@ -28,8 +28,8 @@ fn main() {
assert!(bar1_res);
assert_eq!(bar1_res, bar2_res);
let _foo1_cast: extern fn(u8) -> u8 = foo1;
let _foo2_cast: extern fn(u8) -> u8 = foo2;
let _bar1_cast: unsafe extern fn(bool) -> bool = bar1;
let _bar2_cast: unsafe extern fn(bool) -> bool = bar2;
let _foo1_cast: extern "C" fn(u8) -> u8 = foo1;
let _foo2_cast: extern "C" fn(u8) -> u8 = foo2;
let _bar1_cast: unsafe extern "C" fn(bool) -> bool = bar1;
let _bar2_cast: unsafe extern "C" fn(bool) -> bool = bar2;
}

View File

@ -1,7 +1,7 @@
// run-pass
#![allow(non_upper_case_globals)]
extern fn foopy() {}
extern "C" fn foopy() {}
static f: extern "C" fn() = foopy;
static s: S = S { f: foopy };

View File

@ -1,4 +1,4 @@
pub extern fn bar() {
pub extern "C" fn bar() {
}
pub const foopy: &'static str = "hi there";

View File

@ -6,13 +6,13 @@
pub mod a {
#[no_mangle]
pub extern fn fail() {
pub extern "C" fn fail() {
}
}
pub mod b {
#[no_mangle]
pub extern fn fail() {
pub extern "C" fn fail() {
//~^ symbol `fail` is already defined
}
}

View File

@ -1,8 +1,8 @@
error: symbol `fail` is already defined
--> $DIR/dupe-symbols-2.rs:15:5
|
LL | pub extern fn fail() {
| ^^^^^^^^^^^^^^^^^^^^
LL | pub extern "C" fn fail() {
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error

View File

@ -1,5 +1,5 @@
pub extern fn f() -> i32 { 1 }
pub extern fn g() -> i32 { 2 }
pub extern "C" fn f() -> i32 { 1 }
pub extern "C" fn g() -> i32 { 2 }
pub fn get_f() -> extern fn() -> i32 { f }
pub fn get_g() -> extern fn() -> i32 { g }
pub fn get_f() -> extern "C" fn() -> i32 { f }
pub fn get_g() -> extern "C" fn() -> i32 { g }

View File

@ -15,7 +15,7 @@ pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) {
#[inline(never)]
#[cfg(not(target_arch = "x86_64"))]
pub extern fn foo(a: isize, b: isize, c: isize, d: isize) {
pub extern "C" fn foo(a: isize, b: isize, c: isize, d: isize) {
assert_eq!(a, 1);
assert_eq!(b, 2);
assert_eq!(c, 3);

View File

@ -2,7 +2,7 @@
#![allow(dead_code)]
// pretty-expanded FIXME #23616
extern fn f() {
extern "C" fn f() {
}
pub fn main() {

View File

@ -3,23 +3,23 @@
#![allow(non_camel_case_types)]
// `dbg!()` differentiates these functions to ensure they won't be merged.
extern fn voidret1() { dbg!() }
extern fn voidret2() { dbg!() }
extern "C" fn voidret1() { dbg!() }
extern "C" fn voidret2() { dbg!() }
extern fn uintret() -> usize { 22 }
extern "C" fn uintret() -> usize { 22 }
extern fn uintvoidret(_x: usize) {}
extern "C" fn uintvoidret(_x: usize) {}
extern fn uintuintuintuintret(x: usize, y: usize, z: usize) -> usize { x+y+z }
type uintuintuintuintret = extern fn(usize,usize,usize) -> usize;
extern "C" fn uintuintuintuintret(x: usize, y: usize, z: usize) -> usize { x+y+z }
type uintuintuintuintret = extern "C" fn(usize,usize,usize) -> usize;
pub fn main() {
assert!(voidret1 as extern fn() == voidret1 as extern fn());
assert!(voidret1 as extern fn() != voidret2 as extern fn());
assert!(voidret1 as extern "C" fn() == voidret1 as extern "C" fn());
assert!(voidret1 as extern "C" fn() != voidret2 as extern "C" fn());
assert!(uintret as extern fn() -> usize == uintret as extern fn() -> usize);
assert!(uintret as extern "C" fn() -> usize == uintret as extern "C" fn() -> usize);
assert!(uintvoidret as extern fn(usize) == uintvoidret as extern fn(usize));
assert!(uintvoidret as extern "C" fn(usize) == uintvoidret as extern "C" fn(usize));
assert!(uintuintuintuintret as uintuintuintuintret ==
uintuintuintuintret as uintuintuintuintret);

View File

@ -1 +1 @@
extern fn main() {} //~ ERROR: `main` function has wrong type [E0580]
extern "C" fn main() {} //~ ERROR: `main` function has wrong type [E0580]

View File

@ -1,8 +1,8 @@
error[E0580]: `main` function has wrong type
--> $DIR/extern-main-fn.rs:1:1
|
LL | extern fn main() {}
| ^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn
LL | extern "C" fn main() {}
| ^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn
|
= note: expected fn pointer `fn()`
found fn pointer `extern "C" fn()`

View File

@ -5,7 +5,7 @@
trait A {
extern "fastcall" fn test1(i: i32);
extern fn test2(i: i32);
extern "C" fn test2(i: i32);
}
struct S;
@ -19,7 +19,7 @@ impl A for S {
extern "fastcall" fn test1(i: i32) {
assert_eq!(i, 1);
}
extern fn test2(i: i32) {
extern "C" fn test2(i: i32) {
assert_eq!(i, 2);
}
}

View File

@ -5,7 +5,7 @@
pub struct Foo(u32);
// ICE trigger, bad handling of differing types between rust and external ABIs
pub extern fn bar() -> Foo {
pub extern "C" fn bar() -> Foo {
Foo(0)
}

View File

@ -1,4 +1,4 @@
extern fn f() {
extern "C" fn f() {
}
fn is_fn<F>(_: F) where F: Fn() {}

View File

@ -1,6 +1,6 @@
// run-pass
#![allow(dead_code)]
// pretty-expanded FIXME #23616
#![allow(dead_code)]
unsafe extern fn foo() {}
unsafe extern "C" fn bar() {}

View File

@ -1,2 +1,2 @@
#[no_mangle]
pub extern fn foo() {}
pub extern "C" fn foo() {}

View File

@ -6,7 +6,7 @@
pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
pub extern fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
pub extern "C" fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub fn baz(x: &i32) -> &i32 { x }

View File

@ -6,7 +6,7 @@
pub fn foo<T>() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub extern fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
pub extern "C" fn bar<T>() {} //~ ERROR functions generic over types or consts must be mangled
#[no_mangle]
pub fn baz(x: &i32) -> &i32 { x }

View File

@ -17,8 +17,8 @@ error: functions generic over types or consts must be mangled
|
LL | #[no_mangle]
| ------------ help: remove this attribute
LL | pub extern fn bar<T>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | pub extern "C" fn bar<T>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -23,7 +23,7 @@ mod map_reduce {
pub type putter<'a> = Box<dyn FnMut(String, String) + 'a>;
pub type mapper = extern fn(String, putter);
pub type mapper = extern "C" fn(String, putter);
enum ctrl_proto { find_reducer(Vec<u8>, Sender<isize>), mapper_done, }

View File

@ -1,8 +1,8 @@
pub struct Foo {
pub foo: extern fn()
pub foo: extern "C" fn()
}
extern fn the_foo() {}
extern "C" fn the_foo() {}
pub const FOO: Foo = Foo {
foo: the_foo

View File

@ -1,5 +1,5 @@
fn f(_: extern "Rust" fn()) {}
extern fn bar() {}
extern "C" fn bar() {}
fn main() { f(bar) }
//~^ ERROR mismatched types

View File

@ -16,4 +16,4 @@ pub fn main() {
// The above extern is NOT `extern "rust-intrinsic"` and thus
// means it'll try to find a corresponding symbol to link to.
#[no_mangle]
pub extern fn transmute() {}
pub extern "C" fn transmute() {}

View File

@ -7,7 +7,7 @@ pub struct Foo {
impl Foo {
#[allow(improper_ctypes_definitions)]
pub extern fn foo_new() -> Foo {
pub extern "C" fn foo_new() -> Foo {
Foo { x: 21, y: 33 }
}
}

View File

@ -7,7 +7,7 @@ impl Test {
#[allow(dead_code)]
#[allow(unused_variables)]
#[allow(improper_ctypes_definitions)]
pub extern fn test(val: &str) {
pub extern "C" fn test(val: &str) {
}
}

View File

@ -1,15 +1,15 @@
// run-pass
trait Foo {
extern fn borrow(&self);
extern fn take(self: Box<Self>);
extern "C" fn borrow(&self);
extern "C" fn take(self: Box<Self>);
}
struct Bar;
impl Foo for Bar {
#[allow(improper_ctypes_definitions)]
extern fn borrow(&self) {}
extern "C" fn borrow(&self) {}
#[allow(improper_ctypes_definitions)]
extern fn take(self: Box<Self>) {}
extern "C" fn take(self: Box<Self>) {}
}
fn main() {

View File

@ -27,7 +27,7 @@ pub struct ZeroSize;
pub type RustFn = fn();
pub type RustBadRet = extern fn() -> Box<u32>;
pub type RustBadRet = extern "C" fn() -> Box<u32>;
pub type CVoidRet = ();
@ -116,7 +116,7 @@ pub extern "C" fn transparent_str(p: TransparentStr) { }
pub extern "C" fn transparent_fn(p: TransparentBadFn) { }
pub extern "C" fn good3(fptr: Option<extern fn()>) { }
pub extern "C" fn good3(fptr: Option<extern "C" fn()>) { }
pub extern "C" fn good4(aptr: &[u8; 4 as usize]) { }
@ -124,9 +124,9 @@ pub extern "C" fn good5(s: StructWithProjection) { }
pub extern "C" fn good6(s: StructWithProjectionAndLifetime) { }
pub extern "C" fn good7(fptr: extern fn() -> ()) { }
pub extern "C" fn good7(fptr: extern "C" fn() -> ()) { }
pub extern "C" fn good8(fptr: extern fn() -> !) { }
pub extern "C" fn good8(fptr: extern "C" fn() -> !) { }
pub extern "C" fn good9() -> () { }

View File

@ -75,7 +75,7 @@ fn test8() -> isize {
}
#[allow(improper_ctypes_definitions)]
extern fn simple_extern(x: u32, y: (u32, u32)) -> u32 {
extern "C" fn simple_extern(x: u32, y: (u32, u32)) -> u32 {
x + y.0 * y.1
}

View File

@ -11,6 +11,6 @@ fn main() {
let x = box 1i32;
}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "eh_personality"] extern "C" fn eh_personality() {}
#[lang = "eh_catch_typeinfo"] static EH_CATCH_TYPEINFO: u8 = 0;
#[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} }

View File

@ -31,5 +31,5 @@ macro_rules! check_type {
pub fn main() {
check_type!(&'static isize);
check_type!(Box<isize>);
check_type!(extern fn());
check_type!(extern "C" fn());
}

View File

@ -8,10 +8,10 @@
#![panic_runtime]
#[no_mangle]
pub extern fn __rust_maybe_catch_panic() {}
pub extern "C" fn __rust_maybe_catch_panic() {}
#[no_mangle]
pub extern fn __rust_start_panic() {}
pub extern "C" fn __rust_start_panic() {}
#[no_mangle]
pub extern fn rust_eh_personality() {}
pub extern "C" fn rust_eh_personality() {}

View File

@ -8,10 +8,10 @@
#![panic_runtime]
#[no_mangle]
pub extern fn __rust_maybe_catch_panic() {}
pub extern "C" fn __rust_maybe_catch_panic() {}
#[no_mangle]
pub extern fn __rust_start_panic() {}
pub extern "C" fn __rust_start_panic() {}
#[no_mangle]
pub extern fn rust_eh_personality() {}
pub extern "C" fn rust_eh_personality() {}

View File

@ -8,10 +8,10 @@
#![panic_runtime]
#[no_mangle]
pub extern fn __rust_maybe_catch_panic() {}
pub extern "C" fn __rust_maybe_catch_panic() {}
#[no_mangle]
pub extern fn __rust_start_panic() {}
pub extern "C" fn __rust_start_panic() {}
#[no_mangle]
pub extern fn rust_eh_personality() {}
pub extern "C" fn rust_eh_personality() {}

View File

@ -110,16 +110,5 @@ LL | 1.0e10suffix;
|
= help: valid suffixes are `f32` and `f64`
error: extern declarations without an explicit ABI are deprecated
--> $DIR/bad-lit-suffixes.rs:5:1
|
LL | / extern
LL | | "C"suffix
LL | | {}
| |__^ ABI should be specified here
|
= note: `#[deny(missing_abi)]` on by default
= help: the default ABI is C
error: aborting due to 17 previous errors
error: aborting due to 16 previous errors

View File

@ -7,7 +7,7 @@
extern crate proc_macro;
#[proc_macro_derive(A)]
pub unsafe extern fn foo(a: i32, b: u32) -> u32 {
pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 {
//~^ ERROR: mismatched types
loop {}
}

View File

@ -1,7 +1,7 @@
error[E0308]: mismatched types
--> $DIR/signature.rs:10:1
|
LL | / pub unsafe extern fn foo(a: i32, b: u32) -> u32 {
LL | / pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 {
LL | |
LL | | loop {}
LL | | }

View File

@ -35,7 +35,7 @@ fn c() {
}
#[recollect_attr]
extern fn bar() {
extern "C" fn bar() {
0 //~ ERROR mismatched types
}

View File

@ -37,8 +37,8 @@ LL | let y = Foo { a: 10, b: 10isize };
error[E0308]: mismatched types
--> $DIR/span-preservation.rs:39:5
|
LL | extern fn bar() {
| - possibly return type missing here?
LL | extern "C" fn bar() {
| - possibly return type missing here?
LL | 0
| ^ expected `()`, found integer

View File

@ -13,7 +13,7 @@ use core::ops::RangeBounds;
#[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))]
#[lang = "eh_personality"]
extern fn eh_personality() {}
extern "C" fn eh_personality() {}
#[cfg(target_os = "emscripten")]
#[lang = "eh_catch_typeinfo"]
static EH_CATCH_TYPEINFO: u8 = 0;

View File

@ -13,11 +13,11 @@ extern crate libc;
use libc::*;
unsafe extern fn signal_handler(signum: c_int, _: *mut siginfo_t, _: *mut c_void) {
unsafe extern "C" fn signal_handler(signum: c_int, _: *mut siginfo_t, _: *mut c_void) {
assert_eq!(signum, SIGWINCH);
}
extern fn send_signal() {
extern "C" fn send_signal() {
unsafe {
raise(SIGWINCH);
}

View File

@ -5,7 +5,7 @@
// pretty-expanded FIXME #23616
struct cat {
done : extern fn(usize),
done : extern "C" fn(usize),
meows : usize,
}
@ -15,7 +15,7 @@ impl Drop for cat {
}
}
fn cat(done: extern fn(usize)) -> cat {
fn cat(done: extern "C" fn(usize)) -> cat {
cat {
meows: 0,
done: done

View File

@ -60,7 +60,7 @@ fn main() {
}
// Test type mangling, by putting them in an `impl` header.
impl Bar for [&'_ (dyn Foo<Assoc = extern fn(&u8, ...)> + AutoTrait); 3] {
impl Bar for [&'_ (dyn Foo<Assoc = extern "C" fn(&u8, ...)> + AutoTrait); 3] {
#[rustc_symbol_name]
//[legacy]~^ ERROR symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$3$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method
//[legacy]~| ERROR demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method

View File

@ -6,6 +6,6 @@
// pretty-expanded FIXME #23616
type lteq<T> = extern fn(T) -> bool;
type lteq<T> = extern "C" fn(T) -> bool;
pub fn main() { }

View File

@ -14,7 +14,7 @@ fn range_<F>(lo: usize, hi: usize, mut it: F) where F: FnMut(usize) {
while lo_ < hi { it(lo_); lo_ += 1; }
}
fn create_index<T>(_index: Vec<S<T>> , _hash_fn: extern fn(T) -> usize) {
fn create_index<T>(_index: Vec<S<T>> , _hash_fn: extern "C" fn(T) -> usize) {
range_(0, 256, |_i| {
let _bucket: Vec<T> = Vec::new();
})

View File

@ -3,12 +3,12 @@
// whenever the item path wasn't enough to disambiguate between them.
fn main() {
let a = {
extern fn good() -> i32 { return 0; }
good as extern fn() -> i32
extern "C" fn good() -> i32 { return 0; }
good as extern "C" fn() -> i32
};
let b = {
extern fn good() -> i32 { return 5; }
good as extern fn() -> i32
extern "C" fn good() -> i32 { return 5; }
good as extern "C" fn() -> i32
};
assert!(a != b);