From 4614671cae99ff35e61708ab64e9ba7850711750 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Tue, 1 Sep 2020 17:28:11 -0400 Subject: [PATCH] Update code to account for extern ABI requirement --- .../src/error_codes/E0633.md | 2 +- library/std/src/keyword_docs.rs | 2 +- library/std/src/sys/unix/weak.rs | 2 +- src/test/codegen/debug-linkage-name.rs | 6 ++-- src/test/codegen/export-no-mangle.rs | 8 ++--- src/test/codegen/issue-47278.rs | 2 +- .../codegen/repr-transparent-aggregates-1.rs | 16 ++++----- src/test/codegen/repr-transparent.rs | 34 +++++++++---------- src/test/codegen/target-cpu-on-functions.rs | 2 +- src/test/codegen/unwind-extern-exports.rs | 2 +- src/test/incremental/hashes/inherent_impls.rs | 2 +- src/test/incremental/hashes/trait_defs.rs | 2 +- .../cdylib-dylib-linkage/foo.rs | 4 +-- .../cdylib-fewer-symbols/foo.rs | 2 +- src/test/run-make-fulldeps/cdylib/foo.rs | 4 +-- .../staticlib.rs | 2 +- .../glibc-staticlib-args/library.rs | 2 +- src/test/run-make-fulldeps/issue-14500/foo.rs | 2 +- .../sanitizer-cdylib-link/library.rs | 2 +- .../sanitizer-dylib-link/library.rs | 2 +- .../sanitizer-staticlib-link/library.rs | 2 +- .../static-dylib-by-default/bar.rs | 2 +- .../run-make-fulldeps/std-core-cycle/foo.rs | 2 +- src/test/ui/abi/extern/extern-call-direct.rs | 2 +- .../ui/auxiliary/lto-duplicate-symbols1.rs | 2 +- .../ui/auxiliary/lto-duplicate-symbols2.rs | 2 +- src/test/ui/consts/auxiliary/cci_const.rs | 2 +- src/test/ui/consts/auxiliary/issue-63226.rs | 4 +-- src/test/ui/consts/const-cast.rs | 2 +- .../const-extern-fn-call-extern-fn.rs | 6 ++-- .../const-extern-fn-min-const-fn.rs | 4 +-- .../const-extern-fn-min-const-fn.stderr | 6 ++-- .../const-extern-fn-requires-unsafe.rs | 2 +- .../consts/const-extern-fn/const-extern-fn.rs | 12 +++---- src/test/ui/consts/const-extern-function.rs | 2 +- .../ui/cross-crate/auxiliary/cci_const.rs | 2 +- src/test/ui/duplicate/dupe-symbols-2.rs | 4 +-- src/test/ui/duplicate/dupe-symbols-2.stderr | 4 +-- .../ui/extern/auxiliary/extern-take-value.rs | 8 ++--- .../auxiliary/extern_calling_convention.rs | 2 +- src/test/ui/extern/extern-1.rs | 2 +- .../extern/extern-compare-with-return-type.rs | 20 +++++------ src/test/ui/extern/extern-main-fn.rs | 2 +- src/test/ui/extern/extern-main-fn.stderr | 4 +-- src/test/ui/extern/extern-methods.rs | 4 +-- src/test/ui/extern/extern-rust.rs | 2 +- src/test/ui/extern/extern-wrong-value-type.rs | 2 +- src/test/ui/extern/issue-10025.rs | 2 +- .../ui/functions-closures/auxiliary/fn-abi.rs | 2 +- src/test/ui/generics/generic-no-mangle.fixed | 2 +- src/test/ui/generics/generic-no-mangle.rs | 2 +- src/test/ui/generics/generic-no-mangle.stderr | 4 +-- src/test/ui/hashmap/hashmap-memory.rs | 2 +- src/test/ui/issues/auxiliary/issue-13620-1.rs | 4 +-- src/test/ui/issues/issue-10764.rs | 2 +- src/test/ui/issues/issue-15562.rs | 2 +- src/test/ui/issues/issue-26997.rs | 2 +- src/test/ui/issues/issue-28600.rs | 2 +- src/test/ui/issues/issue-51907.rs | 8 ++--- src/test/ui/lint/lint-ctypes-fn.rs | 8 ++--- src/test/ui/mir/mir_codegen_calls.rs | 2 +- src/test/ui/no_owned_box_lang_item.rs | 2 +- src/test/ui/nullable-pointer-size.rs | 2 +- .../auxiliary/panic-runtime-abort.rs | 6 ++-- .../auxiliary/panic-runtime-unwind.rs | 6 ++-- .../auxiliary/panic-runtime-unwind2.rs | 6 ++-- src/test/ui/parser/bad-lit-suffixes.stderr | 13 +------ src/test/ui/proc-macro/signature.rs | 2 +- src/test/ui/proc-macro/signature.stderr | 2 +- src/test/ui/proc-macro/span-preservation.rs | 2 +- .../ui/proc-macro/span-preservation.stderr | 4 +-- src/test/ui/range/issue-54505-no-std.rs | 2 +- src/test/ui/signal-alternate-stack-cleanup.rs | 4 +-- src/test/ui/structs-enums/class-dtor.rs | 4 +-- src/test/ui/symbol-names/impl1.rs | 2 +- src/test/ui/type-param.rs | 2 +- src/test/ui/type-params-in-for-each.rs | 2 +- src/test/ui/unique/unique-ffi-symbols.rs | 8 ++--- 78 files changed, 155 insertions(+), 166 deletions(-) diff --git a/compiler/rustc_error_codes/src/error_codes/E0633.md b/compiler/rustc_error_codes/src/error_codes/E0633.md index 7f488cde664d9..4d1f0c47829c9 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0633.md +++ b/compiler/rustc_error_codes/src/error_codes/E0633.md @@ -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() {} ``` diff --git a/library/std/src/keyword_docs.rs b/library/std/src/keyword_docs.rs index 417a54e9dffb0..6b06539a0940f 100644 --- a/library/std/src/keyword_docs.rs +++ b/library/std/src/keyword_docs.rs @@ -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 /// } /// ``` diff --git a/library/std/src/sys/unix/weak.rs b/library/std/src/sys/unix/weak.rs index e93a4972caa3e..432fe4c33bcc4 100644 --- a/library/std/src/sys/unix/weak.rs +++ b/library/std/src/sys/unix/weak.rs @@ -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 $ret> = + static $name: crate::sys::weak::Weak $ret> = crate::sys::weak::Weak::new(concat!(stringify!($name), '\0')); ) } diff --git a/src/test/codegen/debug-linkage-name.rs b/src/test/codegen/debug-linkage-name.rs index 0d7dca3aba344..9011a7da51db8 100644 --- a/src/test/codegen/debug-linkage-name.rs +++ b/src/test/codegen/debug-linkage-name.rs @@ -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() {} } diff --git a/src/test/codegen/export-no-mangle.rs b/src/test/codegen/export-no-mangle.rs index 59e97601c838d..a89d48ee1533f 100644 --- a/src/test/codegen/export-no-mangle.rs +++ b/src/test/codegen/export-no-mangle.rs @@ -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() {} } diff --git a/src/test/codegen/issue-47278.rs b/src/test/codegen/issue-47278.rs index 590e8ea850290..9076274f45e94 100644 --- a/src/test/codegen/issue-47278.rs +++ b/src/test/codegen/issue-47278.rs @@ -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 {} } diff --git a/src/test/codegen/repr-transparent-aggregates-1.rs b/src/test/codegen/repr-transparent-aggregates-1.rs index 59f29e756fc9a..2b8d3c8bc1d22 100644 --- a/src/test/codegen/repr-transparent-aggregates-1.rs +++ b/src/test/codegen/repr-transparent-aggregates-1.rs @@ -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 {} } diff --git a/src/test/codegen/repr-transparent.rs b/src/test/codegen/repr-transparent.rs index 7647e0198769c..29997313511b2 100644 --- a/src/test/codegen/repr-transparent.rs +++ b/src/test/codegen/repr-transparent.rs @@ -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); // CHECK: define double @test_Generic(double %_1) #[no_mangle] -pub extern fn test_Generic(_: Generic) -> Generic { loop {} } +pub extern "C" fn test_Generic(_: Generic) -> Generic { loop {} } #[repr(transparent)] pub struct GenericPlusZst(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) -> GenericPlusZst { loop {} } +pub extern "C" fn test_Gpz(_: GenericPlusZst) -> GenericPlusZst { 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) -> LifetimePhantom { loop {} } +pub extern "C" fn test_LifetimePhantom(_: LifetimePhantom) -> LifetimePhantom { 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) -> UnitPhantom { loop {} } +pub extern "C" fn test_UnitPhantom(_: UnitPhantom) -> UnitPhantom { 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); // 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 Mirror for T { type It = Self; } @@ -116,7 +116,7 @@ pub struct StructWithProjection(::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- diff --git a/src/test/codegen/target-cpu-on-functions.rs b/src/test/codegen/target-cpu-on-functions.rs index 523216deb8400..7544ac0130952 100644 --- a/src/test/codegen/target-cpu-on-functions.rs +++ b/src/test/codegen/target-cpu-on-functions.rs @@ -9,7 +9,7 @@ // CHECK-LABEL: define {{.*}} @exported() {{.*}} #0 #[no_mangle] -pub extern fn exported() { +pub extern "C" fn exported() { not_exported(); } diff --git a/src/test/codegen/unwind-extern-exports.rs b/src/test/codegen/unwind-extern-exports.rs index e5a2936b92497..487de20671a2c 100644 --- a/src/test/codegen/unwind-extern-exports.rs +++ b/src/test/codegen/unwind-extern-exports.rs @@ -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.) diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index fcd12ad30ebc9..2e98abae58b3d 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -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) { } } diff --git a/src/test/incremental/hashes/trait_defs.rs b/src/test/incremental/hashes/trait_defs.rs index aa39ea88e0ec0..4dab032e47f35 100644 --- a/src/test/incremental/hashes/trait_defs.rs +++ b/src/test/incremental/hashes/trait_defs.rs @@ -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(); } diff --git a/src/test/run-make-fulldeps/cdylib-dylib-linkage/foo.rs b/src/test/run-make-fulldeps/cdylib-dylib-linkage/foo.rs index c2cc3afcc1322..c4069495aaff1 100644 --- a/src/test/run-make-fulldeps/cdylib-dylib-linkage/foo.rs +++ b/src/test/run-make-fulldeps/cdylib-dylib-linkage/foo.rs @@ -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 } diff --git a/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs b/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs index 5a6f7c45bd284..af37bc8e9534d 100644 --- a/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs +++ b/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs @@ -1,6 +1,6 @@ #![crate_type = "cdylib"] #[no_mangle] -pub extern fn foo() -> u32 { +pub extern "C" fn foo() -> u32 { 3 } diff --git a/src/test/run-make-fulldeps/cdylib/foo.rs b/src/test/run-make-fulldeps/cdylib/foo.rs index c2cc3afcc1322..c4069495aaff1 100644 --- a/src/test/run-make-fulldeps/cdylib/foo.rs +++ b/src/test/run-make-fulldeps/cdylib/foo.rs @@ -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 } diff --git a/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/staticlib.rs b/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/staticlib.rs index b24522e7f0efa..34951dda3b6ec 100644 --- a/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/staticlib.rs +++ b/src/test/run-make-fulldeps/cross-lang-lto-upstream-rlibs/staticlib.rs @@ -3,6 +3,6 @@ extern crate upstream; #[no_mangle] -pub extern fn bar() { +pub extern "C" fn bar() { upstream::foo(); } diff --git a/src/test/run-make-fulldeps/glibc-staticlib-args/library.rs b/src/test/run-make-fulldeps/glibc-staticlib-args/library.rs index 991981dc09666..5ab627a2ac1a2 100644 --- a/src/test/run-make-fulldeps/glibc-staticlib-args/library.rs +++ b/src/test/run-make-fulldeps/glibc-staticlib-args/library.rs @@ -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); } diff --git a/src/test/run-make-fulldeps/issue-14500/foo.rs b/src/test/run-make-fulldeps/issue-14500/foo.rs index feebef1a6d079..7c19c1f2c678a 100644 --- a/src/test/run-make-fulldeps/issue-14500/foo.rs +++ b/src/test/run-make-fulldeps/issue-14500/foo.rs @@ -1,5 +1,5 @@ #[no_mangle] -pub extern fn foo() {} +pub extern "C" fn foo() {} #[no_mangle] pub static FOO_STATIC: u8 = 0; diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs b/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs index bf11553ea6b17..f2a52cb5ca1c5 100644 --- a/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs @@ -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) }; } diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs b/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs index bf11553ea6b17..f2a52cb5ca1c5 100644 --- a/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs @@ -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) }; } diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs b/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs index bf11553ea6b17..f2a52cb5ca1c5 100644 --- a/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs @@ -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) }; } diff --git a/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs b/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs index 5381e7f24bc3a..14421165e2da1 100644 --- a/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs +++ b/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs @@ -3,6 +3,6 @@ extern crate foo; #[no_mangle] -pub extern fn bar() { +pub extern "C" fn bar() { foo::foo(); } diff --git a/src/test/run-make-fulldeps/std-core-cycle/foo.rs b/src/test/run-make-fulldeps/std-core-cycle/foo.rs index 3c80bc45a5b9c..6aa6e1ac3c505 100644 --- a/src/test/run-make-fulldeps/std-core-cycle/foo.rs +++ b/src/test/run-make-fulldeps/std-core-cycle/foo.rs @@ -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 } diff --git a/src/test/ui/abi/extern/extern-call-direct.rs b/src/test/ui/abi/extern/extern-call-direct.rs index 7204176421565..19b901d49a428 100644 --- a/src/test/ui/abi/extern/extern-call-direct.rs +++ b/src/test/ui/abi/extern/extern-call-direct.rs @@ -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); diff --git a/src/test/ui/auxiliary/lto-duplicate-symbols1.rs b/src/test/ui/auxiliary/lto-duplicate-symbols1.rs index 9d510f2626f3a..ec6d056035784 100644 --- a/src/test/ui/auxiliary/lto-duplicate-symbols1.rs +++ b/src/test/ui/auxiliary/lto-duplicate-symbols1.rs @@ -3,4 +3,4 @@ #![crate_type = "rlib"] #[no_mangle] -pub extern fn foo() {} +pub extern "C" fn foo() {} diff --git a/src/test/ui/auxiliary/lto-duplicate-symbols2.rs b/src/test/ui/auxiliary/lto-duplicate-symbols2.rs index 9d510f2626f3a..ec6d056035784 100644 --- a/src/test/ui/auxiliary/lto-duplicate-symbols2.rs +++ b/src/test/ui/auxiliary/lto-duplicate-symbols2.rs @@ -3,4 +3,4 @@ #![crate_type = "rlib"] #[no_mangle] -pub extern fn foo() {} +pub extern "C" fn foo() {} diff --git a/src/test/ui/consts/auxiliary/cci_const.rs b/src/test/ui/consts/auxiliary/cci_const.rs index af6a5ad8ed39d..c83b3f4a5bbf0 100644 --- a/src/test/ui/consts/auxiliary/cci_const.rs +++ b/src/test/ui/consts/auxiliary/cci_const.rs @@ -1,4 +1,4 @@ -pub extern fn bar() { +pub extern "C" fn bar() { } pub const foopy: &'static str = "hi there"; diff --git a/src/test/ui/consts/auxiliary/issue-63226.rs b/src/test/ui/consts/auxiliary/issue-63226.rs index 39cc01a415e9a..2dc9539ba527b 100644 --- a/src/test/ui/consts/auxiliary/issue-63226.rs +++ b/src/test/ui/consts/auxiliary/issue-63226.rs @@ -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() {} diff --git a/src/test/ui/consts/const-cast.rs b/src/test/ui/consts/const-cast.rs index 0d8609e334ac1..abeb24121eb16 100644 --- a/src/test/ui/consts/const-cast.rs +++ b/src/test/ui/consts/const-cast.rs @@ -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 }; diff --git a/src/test/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs b/src/test/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs index e18e0a83573ee..ee07dfae47c38 100644 --- a/src/test/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs +++ b/src/test/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs @@ -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 diff --git a/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs b/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs index 645a957949c41..76380ebcb6599 100644 --- a/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs +++ b/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs @@ -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 diff --git a/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr b/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr index 694e229080870..80d234b0e881e 100644 --- a/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr +++ b/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr @@ -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 for more information = help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable diff --git a/src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs b/src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs index cab175bbfa818..71e6c2cb85859 100644 --- a/src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs +++ b/src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs @@ -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()]; diff --git a/src/test/ui/consts/const-extern-fn/const-extern-fn.rs b/src/test/ui/consts/const-extern-fn/const-extern-fn.rs index 1dc0f83cadf7d..2ce2eafd54507 100644 --- a/src/test/ui/consts/const-extern-fn/const-extern-fn.rs +++ b/src/test/ui/consts/const-extern-fn/const-extern-fn.rs @@ -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; } diff --git a/src/test/ui/consts/const-extern-function.rs b/src/test/ui/consts/const-extern-function.rs index cfcf99b867a01..01f487a7d7558 100644 --- a/src/test/ui/consts/const-extern-function.rs +++ b/src/test/ui/consts/const-extern-function.rs @@ -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 }; diff --git a/src/test/ui/cross-crate/auxiliary/cci_const.rs b/src/test/ui/cross-crate/auxiliary/cci_const.rs index af6a5ad8ed39d..c83b3f4a5bbf0 100644 --- a/src/test/ui/cross-crate/auxiliary/cci_const.rs +++ b/src/test/ui/cross-crate/auxiliary/cci_const.rs @@ -1,4 +1,4 @@ -pub extern fn bar() { +pub extern "C" fn bar() { } pub const foopy: &'static str = "hi there"; diff --git a/src/test/ui/duplicate/dupe-symbols-2.rs b/src/test/ui/duplicate/dupe-symbols-2.rs index d9edd77a19913..e303a790bafca 100644 --- a/src/test/ui/duplicate/dupe-symbols-2.rs +++ b/src/test/ui/duplicate/dupe-symbols-2.rs @@ -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 } } diff --git a/src/test/ui/duplicate/dupe-symbols-2.stderr b/src/test/ui/duplicate/dupe-symbols-2.stderr index 1b29edfb65598..b132eae4b88d7 100644 --- a/src/test/ui/duplicate/dupe-symbols-2.stderr +++ b/src/test/ui/duplicate/dupe-symbols-2.stderr @@ -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 diff --git a/src/test/ui/extern/auxiliary/extern-take-value.rs b/src/test/ui/extern/auxiliary/extern-take-value.rs index 869e794cc8a88..56256aa1927ee 100644 --- a/src/test/ui/extern/auxiliary/extern-take-value.rs +++ b/src/test/ui/extern/auxiliary/extern-take-value.rs @@ -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 } diff --git a/src/test/ui/extern/auxiliary/extern_calling_convention.rs b/src/test/ui/extern/auxiliary/extern_calling_convention.rs index 968b1a2551098..e24cf9fdaa0c5 100644 --- a/src/test/ui/extern/auxiliary/extern_calling_convention.rs +++ b/src/test/ui/extern/auxiliary/extern_calling_convention.rs @@ -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); diff --git a/src/test/ui/extern/extern-1.rs b/src/test/ui/extern/extern-1.rs index eb9aabc87bc8b..66e560501720c 100644 --- a/src/test/ui/extern/extern-1.rs +++ b/src/test/ui/extern/extern-1.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] // pretty-expanded FIXME #23616 -extern fn f() { +extern "C" fn f() { } pub fn main() { diff --git a/src/test/ui/extern/extern-compare-with-return-type.rs b/src/test/ui/extern/extern-compare-with-return-type.rs index 52b51bb943aa6..1ddfc77a4c43a 100644 --- a/src/test/ui/extern/extern-compare-with-return-type.rs +++ b/src/test/ui/extern/extern-compare-with-return-type.rs @@ -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); diff --git a/src/test/ui/extern/extern-main-fn.rs b/src/test/ui/extern/extern-main-fn.rs index ddf2e136f03ce..bb1468a70fb1e 100644 --- a/src/test/ui/extern/extern-main-fn.rs +++ b/src/test/ui/extern/extern-main-fn.rs @@ -1 +1 @@ -extern fn main() {} //~ ERROR: `main` function has wrong type [E0580] +extern "C" fn main() {} //~ ERROR: `main` function has wrong type [E0580] diff --git a/src/test/ui/extern/extern-main-fn.stderr b/src/test/ui/extern/extern-main-fn.stderr index 9c994985a3e0d..136c957538248 100644 --- a/src/test/ui/extern/extern-main-fn.stderr +++ b/src/test/ui/extern/extern-main-fn.stderr @@ -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()` diff --git a/src/test/ui/extern/extern-methods.rs b/src/test/ui/extern/extern-methods.rs index 3c3e229104e0e..97559a6844219 100644 --- a/src/test/ui/extern/extern-methods.rs +++ b/src/test/ui/extern/extern-methods.rs @@ -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); } } diff --git a/src/test/ui/extern/extern-rust.rs b/src/test/ui/extern/extern-rust.rs index 0cb190257be89..7cea8be59215f 100644 --- a/src/test/ui/extern/extern-rust.rs +++ b/src/test/ui/extern/extern-rust.rs @@ -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) } diff --git a/src/test/ui/extern/extern-wrong-value-type.rs b/src/test/ui/extern/extern-wrong-value-type.rs index a4d7b00b1c64e..337865ec18d51 100644 --- a/src/test/ui/extern/extern-wrong-value-type.rs +++ b/src/test/ui/extern/extern-wrong-value-type.rs @@ -1,4 +1,4 @@ -extern fn f() { +extern "C" fn f() { } fn is_fn(_: F) where F: Fn() {} diff --git a/src/test/ui/extern/issue-10025.rs b/src/test/ui/extern/issue-10025.rs index 193d7ee891f07..4439b4685251f 100644 --- a/src/test/ui/extern/issue-10025.rs +++ b/src/test/ui/extern/issue-10025.rs @@ -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() {} diff --git a/src/test/ui/functions-closures/auxiliary/fn-abi.rs b/src/test/ui/functions-closures/auxiliary/fn-abi.rs index 25c9e1b4ca332..ace9fbdfd0c59 100644 --- a/src/test/ui/functions-closures/auxiliary/fn-abi.rs +++ b/src/test/ui/functions-closures/auxiliary/fn-abi.rs @@ -1,2 +1,2 @@ #[no_mangle] -pub extern fn foo() {} +pub extern "C" fn foo() {} diff --git a/src/test/ui/generics/generic-no-mangle.fixed b/src/test/ui/generics/generic-no-mangle.fixed index 72f9af0124c16..207d8a91b0028 100644 --- a/src/test/ui/generics/generic-no-mangle.fixed +++ b/src/test/ui/generics/generic-no-mangle.fixed @@ -6,7 +6,7 @@ pub fn foo() {} //~ ERROR functions generic over types or consts must be mangled -pub extern fn bar() {} //~ ERROR functions generic over types or consts must be mangled +pub extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled #[no_mangle] pub fn baz(x: &i32) -> &i32 { x } diff --git a/src/test/ui/generics/generic-no-mangle.rs b/src/test/ui/generics/generic-no-mangle.rs index 08d631e6eee1e..146896cdc3d02 100644 --- a/src/test/ui/generics/generic-no-mangle.rs +++ b/src/test/ui/generics/generic-no-mangle.rs @@ -6,7 +6,7 @@ pub fn foo() {} //~ ERROR functions generic over types or consts must be mangled #[no_mangle] -pub extern fn bar() {} //~ ERROR functions generic over types or consts must be mangled +pub extern "C" fn bar() {} //~ ERROR functions generic over types or consts must be mangled #[no_mangle] pub fn baz(x: &i32) -> &i32 { x } diff --git a/src/test/ui/generics/generic-no-mangle.stderr b/src/test/ui/generics/generic-no-mangle.stderr index e8e6d9d502d4b..b437417c0b180 100644 --- a/src/test/ui/generics/generic-no-mangle.stderr +++ b/src/test/ui/generics/generic-no-mangle.stderr @@ -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() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub extern "C" fn bar() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/hashmap/hashmap-memory.rs b/src/test/ui/hashmap/hashmap-memory.rs index 3129eb0da82f9..2031196ab215e 100644 --- a/src/test/ui/hashmap/hashmap-memory.rs +++ b/src/test/ui/hashmap/hashmap-memory.rs @@ -23,7 +23,7 @@ mod map_reduce { pub type putter<'a> = Box; - pub type mapper = extern fn(String, putter); + pub type mapper = extern "C" fn(String, putter); enum ctrl_proto { find_reducer(Vec, Sender), mapper_done, } diff --git a/src/test/ui/issues/auxiliary/issue-13620-1.rs b/src/test/ui/issues/auxiliary/issue-13620-1.rs index 1442c0cc7aab3..a77aa5a71553a 100644 --- a/src/test/ui/issues/auxiliary/issue-13620-1.rs +++ b/src/test/ui/issues/auxiliary/issue-13620-1.rs @@ -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 diff --git a/src/test/ui/issues/issue-10764.rs b/src/test/ui/issues/issue-10764.rs index 8fa3607815ad5..bb915f58d9d25 100644 --- a/src/test/ui/issues/issue-10764.rs +++ b/src/test/ui/issues/issue-10764.rs @@ -1,5 +1,5 @@ fn f(_: extern "Rust" fn()) {} -extern fn bar() {} +extern "C" fn bar() {} fn main() { f(bar) } //~^ ERROR mismatched types diff --git a/src/test/ui/issues/issue-15562.rs b/src/test/ui/issues/issue-15562.rs index b37ba81e291e6..dc0ecd365226c 100644 --- a/src/test/ui/issues/issue-15562.rs +++ b/src/test/ui/issues/issue-15562.rs @@ -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() {} diff --git a/src/test/ui/issues/issue-26997.rs b/src/test/ui/issues/issue-26997.rs index fcabd1d84557c..3653e62732d41 100644 --- a/src/test/ui/issues/issue-26997.rs +++ b/src/test/ui/issues/issue-26997.rs @@ -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 } } } diff --git a/src/test/ui/issues/issue-28600.rs b/src/test/ui/issues/issue-28600.rs index 297519b9a79e2..52db0d5fd84a9 100644 --- a/src/test/ui/issues/issue-28600.rs +++ b/src/test/ui/issues/issue-28600.rs @@ -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) { } } diff --git a/src/test/ui/issues/issue-51907.rs b/src/test/ui/issues/issue-51907.rs index 52d26d0954af8..9378f4357134b 100644 --- a/src/test/ui/issues/issue-51907.rs +++ b/src/test/ui/issues/issue-51907.rs @@ -1,15 +1,15 @@ // run-pass trait Foo { - extern fn borrow(&self); - extern fn take(self: Box); + extern "C" fn borrow(&self); + extern "C" fn take(self: Box); } 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) {} + extern "C" fn take(self: Box) {} } fn main() { diff --git a/src/test/ui/lint/lint-ctypes-fn.rs b/src/test/ui/lint/lint-ctypes-fn.rs index 170a04efb07c6..e69d0dab49642 100644 --- a/src/test/ui/lint/lint-ctypes-fn.rs +++ b/src/test/ui/lint/lint-ctypes-fn.rs @@ -27,7 +27,7 @@ pub struct ZeroSize; pub type RustFn = fn(); -pub type RustBadRet = extern fn() -> Box; +pub type RustBadRet = extern "C" fn() -> Box; 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) { } +pub extern "C" fn good3(fptr: Option) { } 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() -> () { } diff --git a/src/test/ui/mir/mir_codegen_calls.rs b/src/test/ui/mir/mir_codegen_calls.rs index d93a25c8ef4d3..6a5a4dace6492 100644 --- a/src/test/ui/mir/mir_codegen_calls.rs +++ b/src/test/ui/mir/mir_codegen_calls.rs @@ -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 } diff --git a/src/test/ui/no_owned_box_lang_item.rs b/src/test/ui/no_owned_box_lang_item.rs index bef630d826c0f..c22b44ffca2a4 100644 --- a/src/test/ui/no_owned_box_lang_item.rs +++ b/src/test/ui/no_owned_box_lang_item.rs @@ -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 {} } diff --git a/src/test/ui/nullable-pointer-size.rs b/src/test/ui/nullable-pointer-size.rs index 63a106f129282..0384553b6993f 100644 --- a/src/test/ui/nullable-pointer-size.rs +++ b/src/test/ui/nullable-pointer-size.rs @@ -31,5 +31,5 @@ macro_rules! check_type { pub fn main() { check_type!(&'static isize); check_type!(Box); - check_type!(extern fn()); + check_type!(extern "C" fn()); } diff --git a/src/test/ui/panic-runtime/auxiliary/panic-runtime-abort.rs b/src/test/ui/panic-runtime/auxiliary/panic-runtime-abort.rs index 433301fb43441..c92015eeebcc2 100644 --- a/src/test/ui/panic-runtime/auxiliary/panic-runtime-abort.rs +++ b/src/test/ui/panic-runtime/auxiliary/panic-runtime-abort.rs @@ -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() {} diff --git a/src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs b/src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs index 97452a342ab4d..2f7aed9248a06 100644 --- a/src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs +++ b/src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind.rs @@ -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() {} diff --git a/src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs b/src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs index 97452a342ab4d..2f7aed9248a06 100644 --- a/src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs +++ b/src/test/ui/panic-runtime/auxiliary/panic-runtime-unwind2.rs @@ -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() {} diff --git a/src/test/ui/parser/bad-lit-suffixes.stderr b/src/test/ui/parser/bad-lit-suffixes.stderr index 8c4339614080b..9b596571481b9 100644 --- a/src/test/ui/parser/bad-lit-suffixes.stderr +++ b/src/test/ui/parser/bad-lit-suffixes.stderr @@ -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 diff --git a/src/test/ui/proc-macro/signature.rs b/src/test/ui/proc-macro/signature.rs index dbc1577172f03..e08928716b05b 100644 --- a/src/test/ui/proc-macro/signature.rs +++ b/src/test/ui/proc-macro/signature.rs @@ -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 {} } diff --git a/src/test/ui/proc-macro/signature.stderr b/src/test/ui/proc-macro/signature.stderr index 6ebc99601c41f..80a459c41257f 100644 --- a/src/test/ui/proc-macro/signature.stderr +++ b/src/test/ui/proc-macro/signature.stderr @@ -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 | | } diff --git a/src/test/ui/proc-macro/span-preservation.rs b/src/test/ui/proc-macro/span-preservation.rs index b22e50c4c1715..0c73586555822 100644 --- a/src/test/ui/proc-macro/span-preservation.rs +++ b/src/test/ui/proc-macro/span-preservation.rs @@ -35,7 +35,7 @@ fn c() { } #[recollect_attr] -extern fn bar() { +extern "C" fn bar() { 0 //~ ERROR mismatched types } diff --git a/src/test/ui/proc-macro/span-preservation.stderr b/src/test/ui/proc-macro/span-preservation.stderr index 4064c5b3819ec..9e91ed4068b1f 100644 --- a/src/test/ui/proc-macro/span-preservation.stderr +++ b/src/test/ui/proc-macro/span-preservation.stderr @@ -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 diff --git a/src/test/ui/range/issue-54505-no-std.rs b/src/test/ui/range/issue-54505-no-std.rs index f5d5823e468b0..ab1a025b521a9 100644 --- a/src/test/ui/range/issue-54505-no-std.rs +++ b/src/test/ui/range/issue-54505-no-std.rs @@ -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; diff --git a/src/test/ui/signal-alternate-stack-cleanup.rs b/src/test/ui/signal-alternate-stack-cleanup.rs index 15fcf78893ebb..8a6d738959e4c 100644 --- a/src/test/ui/signal-alternate-stack-cleanup.rs +++ b/src/test/ui/signal-alternate-stack-cleanup.rs @@ -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); } diff --git a/src/test/ui/structs-enums/class-dtor.rs b/src/test/ui/structs-enums/class-dtor.rs index ee1cac03c81e8..583a5e2409859 100644 --- a/src/test/ui/structs-enums/class-dtor.rs +++ b/src/test/ui/structs-enums/class-dtor.rs @@ -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 diff --git a/src/test/ui/symbol-names/impl1.rs b/src/test/ui/symbol-names/impl1.rs index 05bd98df0064a..24bdf6d669e88 100644 --- a/src/test/ui/symbol-names/impl1.rs +++ b/src/test/ui/symbol-names/impl1.rs @@ -60,7 +60,7 @@ fn main() { } // Test type mangling, by putting them in an `impl` header. - impl Bar for [&'_ (dyn Foo + AutoTrait); 3] { + impl Bar for [&'_ (dyn Foo + 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 diff --git a/src/test/ui/type-param.rs b/src/test/ui/type-param.rs index f5ac19cf73aa8..ca2f24d379bc6 100644 --- a/src/test/ui/type-param.rs +++ b/src/test/ui/type-param.rs @@ -6,6 +6,6 @@ // pretty-expanded FIXME #23616 -type lteq = extern fn(T) -> bool; +type lteq = extern "C" fn(T) -> bool; pub fn main() { } diff --git a/src/test/ui/type-params-in-for-each.rs b/src/test/ui/type-params-in-for-each.rs index be4a0185edaf4..53475d2804794 100644 --- a/src/test/ui/type-params-in-for-each.rs +++ b/src/test/ui/type-params-in-for-each.rs @@ -14,7 +14,7 @@ fn range_(lo: usize, hi: usize, mut it: F) where F: FnMut(usize) { while lo_ < hi { it(lo_); lo_ += 1; } } -fn create_index(_index: Vec> , _hash_fn: extern fn(T) -> usize) { +fn create_index(_index: Vec> , _hash_fn: extern "C" fn(T) -> usize) { range_(0, 256, |_i| { let _bucket: Vec = Vec::new(); }) diff --git a/src/test/ui/unique/unique-ffi-symbols.rs b/src/test/ui/unique/unique-ffi-symbols.rs index b0fe22bc33269..77b5ead26337a 100644 --- a/src/test/ui/unique/unique-ffi-symbols.rs +++ b/src/test/ui/unique/unique-ffi-symbols.rs @@ -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);