diff --git a/compiler/rustc_codegen_gcc/example/mini_core.rs b/compiler/rustc_codegen_gcc/example/mini_core.rs index 0576b64ef6fa5..580c4622e3dbd 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core.rs @@ -639,7 +639,7 @@ impl Index for [T] { } } -extern { +extern "C" { type VaListImpl; } diff --git a/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs index dcfa34cb729d8..1d51e0a1856ba 100644 --- a/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs +++ b/compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs @@ -258,13 +258,13 @@ fn main() { assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42); - extern { + extern "C" { #[linkage = "weak"] static ABC: *const u8; } { - extern { + extern "C" { #[linkage = "weak"] static ABC: *const u8; } diff --git a/compiler/rustc_codegen_gcc/example/mod_bench.rs b/compiler/rustc_codegen_gcc/example/mod_bench.rs index cae911c1073d5..e8a9cade74745 100644 --- a/compiler/rustc_codegen_gcc/example/mod_bench.rs +++ b/compiler/rustc_codegen_gcc/example/mod_bench.rs @@ -3,7 +3,7 @@ #![allow(internal_features)] #[link(name = "c")] -extern {} +extern "C" {} #[panic_handler] fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! { diff --git a/compiler/rustc_codegen_gcc/example/std_example.rs b/compiler/rustc_codegen_gcc/example/std_example.rs index 9e43b4635f0d3..5fa1e0afb0603 100644 --- a/compiler/rustc_codegen_gcc/example/std_example.rs +++ b/compiler/rustc_codegen_gcc/example/std_example.rs @@ -7,7 +7,7 @@ use std::arch::x86_64::*; use std::io::Write; use std::ops::Coroutine; -extern { +extern "C" { pub fn printf(format: *const i8, ...) -> i32; } diff --git a/src/tools/clippy/tests/ui/boxed_local.rs b/src/tools/clippy/tests/ui/boxed_local.rs index e2c27e585fce8..4f361f5162be4 100644 --- a/src/tools/clippy/tests/ui/boxed_local.rs +++ b/src/tools/clippy/tests/ui/boxed_local.rs @@ -173,6 +173,7 @@ mod issue_3739 { /// This shouldn't warn for `boxed_local` as it is intended to called from non-Rust code. pub extern "C" fn do_not_warn_me(_c_pointer: Box) -> () {} +#[allow(missing_abi)] #[rustfmt::skip] // Forces rustfmt to not add ABI pub extern fn do_not_warn_me_no_abi(_c_pointer: Box) -> () {} diff --git a/src/tools/clippy/tests/ui/boxed_local.stderr b/src/tools/clippy/tests/ui/boxed_local.stderr index d3156c820b2c5..08fe375afb235 100644 --- a/src/tools/clippy/tests/ui/boxed_local.stderr +++ b/src/tools/clippy/tests/ui/boxed_local.stderr @@ -14,13 +14,13 @@ LL | pub fn new(_needs_name: Box>) -> () {} | ^^^^^^^^^^^ error: local variable doesn't need to be boxed here - --> tests/ui/boxed_local.rs:188:44 + --> tests/ui/boxed_local.rs:189:44 | LL | fn default_impl_x(self: Box, x: Box) -> u32 { | ^ error: local variable doesn't need to be boxed here - --> tests/ui/boxed_local.rs:196:16 + --> tests/ui/boxed_local.rs:197:16 | LL | fn foo(x: Box) {} | ^ diff --git a/src/tools/clippy/tests/ui/doc/doc-fixable.fixed b/src/tools/clippy/tests/ui/doc/doc-fixable.fixed index 355f2bc773611..03c092a470276 100644 --- a/src/tools/clippy/tests/ui/doc/doc-fixable.fixed +++ b/src/tools/clippy/tests/ui/doc/doc-fixable.fixed @@ -239,7 +239,7 @@ fn parenthesized_word() {} /// UXes fn plural_acronym_test() {} -extern { +extern "C" { /// `foo()` fn in_extern(); } diff --git a/src/tools/clippy/tests/ui/doc/doc-fixable.rs b/src/tools/clippy/tests/ui/doc/doc-fixable.rs index 9ced267762210..224355868d031 100644 --- a/src/tools/clippy/tests/ui/doc/doc-fixable.rs +++ b/src/tools/clippy/tests/ui/doc/doc-fixable.rs @@ -239,7 +239,7 @@ fn parenthesized_word() {} /// UXes fn plural_acronym_test() {} -extern { +extern "C" { /// foo() fn in_extern(); } diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.fixed b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.fixed index f7b6e1a186bbd..48e7b5cfc7c74 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.fixed +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.fixed @@ -150,6 +150,7 @@ mod msrv { //~^ ERROR: this could be a `const fn` #[rustfmt::skip] + #[allow(missing_abi)] const extern fn implicit_c() {} //~^ ERROR: this could be a `const fn` diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs index 4866e3210245e..f92e36a0f6312 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs @@ -150,6 +150,7 @@ mod msrv { //~^ ERROR: this could be a `const fn` #[rustfmt::skip] + #[allow(missing_abi)] extern fn implicit_c() {} //~^ ERROR: this could be a `const fn` diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr index f28dec5c7f195..2691dc973ea10 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr @@ -222,7 +222,7 @@ LL | const extern "C" fn c() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:153:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:154:9 | LL | extern fn implicit_c() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -233,7 +233,7 @@ LL | const extern fn implicit_c() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:170:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:171:9 | LL | / pub fn new(strings: Vec) -> Self { LL | | Self { strings } @@ -246,7 +246,7 @@ LL | pub const fn new(strings: Vec) -> Self { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:175:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:176:9 | LL | / pub fn empty() -> Self { LL | | Self { strings: Vec::new() } @@ -259,7 +259,7 @@ LL | pub const fn empty() -> Self { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:186:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:187:9 | LL | / pub fn new(text: String) -> Self { LL | | let vec = Vec::new(); @@ -273,7 +273,7 @@ LL | pub const fn new(text: String) -> Self { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:205:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:206:5 | LL | fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -284,7 +284,7 @@ LL | const fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:209:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:210:5 | LL | extern "C-unwind" fn c_unwind() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +295,7 @@ LL | const extern "C-unwind" fn c_unwind() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:211:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:212:5 | LL | extern "system" fn system() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -306,7 +306,7 @@ LL | const extern "system" fn system() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:213:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:214:5 | LL | extern "system-unwind" fn system_unwind() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -317,7 +317,7 @@ LL | const extern "system-unwind" fn system_unwind() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:215:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:216:5 | LL | pub extern "vectorcall" fn std_call() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -328,7 +328,7 @@ LL | pub const extern "vectorcall" fn std_call() {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:217:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:218:5 | LL | pub extern "vectorcall-unwind" fn std_call_unwind() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/associated-types/issue-91231.rs b/tests/ui/associated-types/issue-91231.rs index d1c99fd44fa02..a04ab60a7fcdb 100644 --- a/tests/ui/associated-types/issue-91231.rs +++ b/tests/ui/associated-types/issue-91231.rs @@ -3,7 +3,7 @@ #![feature(extern_types)] #![allow(dead_code)] -extern { +extern "C" { type Extern; } diff --git a/tests/ui/attributes/key-value-expansion.rs b/tests/ui/attributes/key-value-expansion.rs index dd408ebb77e4c..5a90efe88fb09 100644 --- a/tests/ui/attributes/key-value-expansion.rs +++ b/tests/ui/attributes/key-value-expansion.rs @@ -39,7 +39,7 @@ bug!(); macro_rules! doc_comment { ($x:expr) => { #[doc = $x] - extern {} + extern "C" {} }; } diff --git a/tests/ui/borrowck/issue-92157.rs b/tests/ui/borrowck/issue-92157.rs index 3a6f8908b219f..a2b685cdf6ede 100644 --- a/tests/ui/borrowck/issue-92157.rs +++ b/tests/ui/borrowck/issue-92157.rs @@ -5,7 +5,7 @@ #[cfg(target_os = "linux")] #[link(name = "c")] -extern {} +extern "C" {} #[lang = "start"] fn start(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize { diff --git a/tests/ui/coherence/coherence-negative-impls-copy.rs b/tests/ui/coherence/coherence-negative-impls-copy.rs index 377d750f8baa4..c0d852180a518 100644 --- a/tests/ui/coherence/coherence-negative-impls-copy.rs +++ b/tests/ui/coherence/coherence-negative-impls-copy.rs @@ -18,7 +18,7 @@ impl !Copy for WithDrop {} struct Type; trait Trait {} -extern { +extern "C" { type ExternType; } diff --git a/tests/ui/conditional-compilation/cfg_accessible-not_sure.rs b/tests/ui/conditional-compilation/cfg_accessible-not_sure.rs index e357d3c6cb56f..2ac57f356740f 100644 --- a/tests/ui/conditional-compilation/cfg_accessible-not_sure.rs +++ b/tests/ui/conditional-compilation/cfg_accessible-not_sure.rs @@ -63,7 +63,7 @@ const B: bool = true; // ForeignType::unresolved - error -extern { +extern "C" { type ForeignType; } diff --git a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs index 3502409d576c2..8a32b170c40a4 100644 --- a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs +++ b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs @@ -1,6 +1,6 @@ #![feature(extern_types)] -extern { +extern "C" { type Opaque; } diff --git a/tests/ui/delegation/glob-non-impl.rs b/tests/ui/delegation/glob-non-impl.rs index d523731eeb35f..e3a4061fb15a6 100644 --- a/tests/ui/delegation/glob-non-impl.rs +++ b/tests/ui/delegation/glob-non-impl.rs @@ -11,7 +11,7 @@ trait OtherTrait { reuse Trait::*; //~ ERROR glob delegation is only supported in impls } -extern { +extern "C" { reuse Trait::*; //~ ERROR delegation is not supported in `extern` blocks } diff --git a/tests/ui/extern/extern-type-diag-not-similar.rs b/tests/ui/extern/extern-type-diag-not-similar.rs index 39d00a6c1bc31..cd3eec9f1f7b8 100644 --- a/tests/ui/extern/extern-type-diag-not-similar.rs +++ b/tests/ui/extern/extern-type-diag-not-similar.rs @@ -4,11 +4,11 @@ // because they are both extern types. #![feature(extern_types)] -extern { +extern "C" { type ShouldNotBeMentioned; } -extern { +extern "C" { type Foo; } diff --git a/tests/ui/extern/issue-10025.rs b/tests/ui/extern/issue-10025.rs index 0bdcf7c5c5875..0eec924290841 100644 --- a/tests/ui/extern/issue-10025.rs +++ b/tests/ui/extern/issue-10025.rs @@ -1,6 +1,6 @@ //@ run-pass //@ pretty-expanded FIXME #23616 -#![allow(dead_code)] +#![allow(dead_code, missing_abi)] unsafe extern fn foo() {} unsafe extern "C" fn bar() {} diff --git a/tests/ui/extern/issue-95829.rs b/tests/ui/extern/issue-95829.rs index c5ae4c6826597..493d53d2532f2 100644 --- a/tests/ui/extern/issue-95829.rs +++ b/tests/ui/extern/issue-95829.rs @@ -1,6 +1,6 @@ //@ edition:2018 -extern { +extern "C" { async fn L() { //~ ERROR: incorrect function inside `extern` block //~^ ERROR: functions in `extern` blocks cannot have `async` qualifier async fn M() {} diff --git a/tests/ui/extern/issue-95829.stderr b/tests/ui/extern/issue-95829.stderr index 2f396b8cc0415..2acd0fa3a2650 100644 --- a/tests/ui/extern/issue-95829.stderr +++ b/tests/ui/extern/issue-95829.stderr @@ -1,8 +1,8 @@ error: incorrect function inside `extern` block --> $DIR/issue-95829.rs:4:14 | -LL | extern { - | ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body +LL | extern "C" { + | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body LL | async fn L() { | ______________^___- | | | @@ -18,8 +18,8 @@ LL | | } error: functions in `extern` blocks cannot have `async` qualifier --> $DIR/issue-95829.rs:4:5 | -LL | extern { - | ------ in this `extern` block +LL | extern "C" { + | ---------- in this `extern` block LL | async fn L() { | ^^^^^ help: remove the `async` qualifier diff --git a/tests/ui/extern/not-in-block.rs b/tests/ui/extern/not-in-block.rs index d3bcafdef7b3c..c21616350902e 100644 --- a/tests/ui/extern/not-in-block.rs +++ b/tests/ui/extern/not-in-block.rs @@ -1,4 +1,5 @@ #![crate_type = "lib"] +#![allow(missing_abi)] extern fn none_fn(x: bool) -> i32; //~^ ERROR free function without a body diff --git a/tests/ui/extern/not-in-block.stderr b/tests/ui/extern/not-in-block.stderr index 2544949ab17a8..f86c279a23424 100644 --- a/tests/ui/extern/not-in-block.stderr +++ b/tests/ui/extern/not-in-block.stderr @@ -1,5 +1,5 @@ error: free function without a body - --> $DIR/not-in-block.rs:3:1 + --> $DIR/not-in-block.rs:4:1 | LL | extern fn none_fn(x: bool) -> i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL | extern { fn none_fn(x: bool) -> i32; } | ~~~~~~~~ + error: free function without a body - --> $DIR/not-in-block.rs:5:1 + --> $DIR/not-in-block.rs:6:1 | LL | extern "C" fn c_fn(x: bool) -> i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs index 2ac3ca29355d8..e8634de86ea49 100644 --- a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs +++ b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs @@ -1,6 +1,6 @@ // Regression test for issue #91370. -extern { +extern "C" { //~^ `extern` blocks define existing foreign functions fn f() { //~^ incorrect function inside `extern` block diff --git a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr index fea2ab61e929f..155fdf9d09ab0 100644 --- a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr +++ b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr @@ -1,8 +1,8 @@ error: incorrect function inside `extern` block --> $DIR/issue-91370-foreign-fn-block-impl.rs:5:8 | -LL | extern { - | ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body +LL | extern "C" { + | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body LL | LL | fn f() { | ________^___- diff --git a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs index 6eabd9b1015b7..73a0363904aeb 100644 --- a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs +++ b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs @@ -21,7 +21,7 @@ struct S; #[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes fn foo6() {} -extern { +extern "C" { #[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function fn foo7(); //~ ERROR foreign items may not have const parameters } diff --git a/tests/ui/linkage-attr/issue-109144.rs b/tests/ui/linkage-attr/issue-109144.rs index 2f740e5538973..6970a4989bb53 100644 --- a/tests/ui/linkage-attr/issue-109144.rs +++ b/tests/ui/linkage-attr/issue-109144.rs @@ -1,4 +1,4 @@ #![crate_type = "lib"] #[link(kind = "static", modifiers = "+whole-archive,+bundle")] //~^ ERROR `#[link]` attribute requires a `name = "string"` argument -extern {} +extern "C" {} diff --git a/tests/ui/lint/function-item-references.rs b/tests/ui/lint/function-item-references.rs index 918d72e28a918..4f2fc4de8632e 100644 --- a/tests/ui/lint/function-item-references.rs +++ b/tests/ui/lint/function-item-references.rs @@ -11,7 +11,7 @@ fn baz(x: u32, y: u32) -> u32 { x + y } unsafe fn unsafe_fn() { } extern "C" fn c_fn() { } unsafe extern "C" fn unsafe_c_fn() { } -unsafe extern fn variadic(_x: u32, _args: ...) { } +unsafe extern "C" fn variadic(_x: u32, _args: ...) { } fn take_generic_ref<'a, T>(_x: &'a T) { } fn take_generic_array(_x: [T; N]) { } fn multiple_generic(_x: T, _y: U) { } diff --git a/tests/ui/lint/lint-ctypes.rs b/tests/ui/lint/lint-ctypes.rs index dae07930aba60..6dd9be10a48f8 100644 --- a/tests/ui/lint/lint-ctypes.rs +++ b/tests/ui/lint/lint-ctypes.rs @@ -72,7 +72,7 @@ extern "C" { pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `Box` pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]` - pub fn no_niche_a(a: Option>); + pub fn no_niche_a(a: Option>); //~^ ERROR: uses type `Option>` pub fn no_niche_b(b: Option>); //~^ ERROR: uses type `Option>` diff --git a/tests/ui/lint/lint-ctypes.stderr b/tests/ui/lint/lint-ctypes.stderr index 2c81c7b8e4b67..8137ae868d356 100644 --- a/tests/ui/lint/lint-ctypes.stderr +++ b/tests/ui/lint/lint-ctypes.stderr @@ -227,8 +227,8 @@ LL | pub fn raw_array(arr: [u8; 8]); error: `extern` block uses type `Option>`, which is not FFI-safe --> $DIR/lint-ctypes.rs:75:26 | -LL | pub fn no_niche_a(a: Option>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | pub fn no_niche_a(a: Option>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint diff --git a/tests/ui/native-library-link-flags/suggest-libname-only-1.stderr b/tests/ui/native-library-link-flags/suggest-libname-only-1.stderr index e142835a9d64c..aae8f7de966a0 100644 --- a/tests/ui/native-library-link-flags/suggest-libname-only-1.stderr +++ b/tests/ui/native-library-link-flags/suggest-libname-only-1.stderr @@ -1,6 +1,14 @@ +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/suggest-libname-only-1.rs:7:1 + | +LL | extern { } + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + error: could not find native static library `libfoo.a`, perhaps an -L flag is missing? | = help: only provide the library name `foo`, not the full filename -error: aborting due to 1 previous error +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/native-library-link-flags/suggest-libname-only-2.stderr b/tests/ui/native-library-link-flags/suggest-libname-only-2.stderr index 392d2f01f619b..a2adaee3f97f5 100644 --- a/tests/ui/native-library-link-flags/suggest-libname-only-2.stderr +++ b/tests/ui/native-library-link-flags/suggest-libname-only-2.stderr @@ -1,6 +1,14 @@ +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/suggest-libname-only-2.rs:7:1 + | +LL | extern { } + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + error: could not find native static library `bar.lib`, perhaps an -L flag is missing? | = help: only provide the library name `bar`, not the full filename -error: aborting due to 1 previous error +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/offset-of/offset-of-dst-field.rs b/tests/ui/offset-of/offset-of-dst-field.rs index 5ae15f323577f..2e0bdb151e180 100644 --- a/tests/ui/offset-of/offset-of-dst-field.rs +++ b/tests/ui/offset-of/offset-of-dst-field.rs @@ -16,7 +16,7 @@ struct Beta { z: dyn Trait, } -extern { +extern "C" { type Extern; } diff --git a/tests/ui/parser/bad-fn-ptr-qualifier.fixed b/tests/ui/parser/bad-fn-ptr-qualifier.fixed index 558a27cd4562d..e2a2f9486b785 100644 --- a/tests/ui/parser/bad-fn-ptr-qualifier.fixed +++ b/tests/ui/parser/bad-fn-ptr-qualifier.fixed @@ -4,9 +4,9 @@ pub type T0 = fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T1 = extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -pub type T2 = unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +pub type T2 = unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T3 = fn(); //~ ERROR an `fn` pointer type cannot be `async` -pub type T4 = extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +pub type T4 = extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T5 = unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T6 = unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `const` @@ -14,9 +14,9 @@ pub type T6 = unsafe extern "C" fn(); pub type FTT0 = for<'a> fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT1 = for<'a> extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -pub type FTT2 = for<'a> unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +pub type FTT2 = for<'a> unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT3 = for<'a> fn(); //~ ERROR an `fn` pointer type cannot be `async` -pub type FTT4 = for<'a> extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +pub type FTT4 = for<'a> extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type FTT5 = for<'a> unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `async` pub type FTT6 = for<'a> unsafe extern "C" fn(); diff --git a/tests/ui/parser/bad-fn-ptr-qualifier.rs b/tests/ui/parser/bad-fn-ptr-qualifier.rs index 9750f480935f2..f2611c93b1763 100644 --- a/tests/ui/parser/bad-fn-ptr-qualifier.rs +++ b/tests/ui/parser/bad-fn-ptr-qualifier.rs @@ -4,9 +4,9 @@ pub type T0 = const fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T1 = const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -pub type T2 = const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +pub type T2 = const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T3 = async fn(); //~ ERROR an `fn` pointer type cannot be `async` -pub type T4 = async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +pub type T4 = async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T5 = async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T6 = const async unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `const` @@ -14,9 +14,9 @@ pub type T6 = const async unsafe extern "C" fn(); pub type FTT0 = for<'a> const fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT1 = for<'a> const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -pub type FTT2 = for<'a> const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +pub type FTT2 = for<'a> const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT3 = for<'a> async fn(); //~ ERROR an `fn` pointer type cannot be `async` -pub type FTT4 = for<'a> async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +pub type FTT4 = for<'a> async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type FTT5 = for<'a> async unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `async` pub type FTT6 = for<'a> const async unsafe extern "C" fn(); diff --git a/tests/ui/parser/bad-fn-ptr-qualifier.stderr b/tests/ui/parser/bad-fn-ptr-qualifier.stderr index 523ee47b0c942..ddc8bac678cfb 100644 --- a/tests/ui/parser/bad-fn-ptr-qualifier.stderr +++ b/tests/ui/parser/bad-fn-ptr-qualifier.stderr @@ -29,15 +29,15 @@ LL + pub type T1 = extern "C" fn(); error: an `fn` pointer type cannot be `const` --> $DIR/bad-fn-ptr-qualifier.rs:7:15 | -LL | pub type T2 = const unsafe extern fn(); - | -----^^^^^^^^^^^^^^^^^^^ +LL | pub type T2 = const unsafe extern "C" fn(); + | -----^^^^^^^^^^^^^^^^^^^^^^^ | | | `const` because of this | help: remove the `const` qualifier | -LL - pub type T2 = const unsafe extern fn(); -LL + pub type T2 = unsafe extern fn(); +LL - pub type T2 = const unsafe extern "C" fn(); +LL + pub type T2 = unsafe extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -57,15 +57,15 @@ LL + pub type T3 = fn(); error: an `fn` pointer type cannot be `async` --> $DIR/bad-fn-ptr-qualifier.rs:9:15 | -LL | pub type T4 = async extern fn(); - | -----^^^^^^^^^^^^ +LL | pub type T4 = async extern "C" fn(); + | -----^^^^^^^^^^^^^^^^ | | | `async` because of this | help: remove the `async` qualifier | -LL - pub type T4 = async extern fn(); -LL + pub type T4 = extern fn(); +LL - pub type T4 = async extern "C" fn(); +LL + pub type T4 = extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -141,15 +141,15 @@ LL + pub type FTT1 = for<'a> extern "C" fn(); error: an `fn` pointer type cannot be `const` --> $DIR/bad-fn-ptr-qualifier.rs:17:17 | -LL | pub type FTT2 = for<'a> const unsafe extern fn(); - | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^ +LL | pub type FTT2 = for<'a> const unsafe extern "C" fn(); + | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^ | | | `const` because of this | help: remove the `const` qualifier | -LL - pub type FTT2 = for<'a> const unsafe extern fn(); -LL + pub type FTT2 = for<'a> unsafe extern fn(); +LL - pub type FTT2 = for<'a> const unsafe extern "C" fn(); +LL + pub type FTT2 = for<'a> unsafe extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -169,15 +169,15 @@ LL + pub type FTT3 = for<'a> fn(); error: an `fn` pointer type cannot be `async` --> $DIR/bad-fn-ptr-qualifier.rs:19:17 | -LL | pub type FTT4 = for<'a> async extern fn(); - | ^^^^^^^^-----^^^^^^^^^^^^ +LL | pub type FTT4 = for<'a> async extern "C" fn(); + | ^^^^^^^^-----^^^^^^^^^^^^^^^^ | | | `async` because of this | help: remove the `async` qualifier | -LL - pub type FTT4 = for<'a> async extern fn(); -LL + pub type FTT4 = for<'a> extern fn(); +LL - pub type FTT4 = for<'a> async extern "C" fn(); +LL + pub type FTT4 = for<'a> extern "C" fn(); | error: an `fn` pointer type cannot be `async` diff --git a/tests/ui/parser/bad-lit-suffixes.rs b/tests/ui/parser/bad-lit-suffixes.rs index c614f49388574..f29dc53d322b9 100644 --- a/tests/ui/parser/bad-lit-suffixes.rs +++ b/tests/ui/parser/bad-lit-suffixes.rs @@ -1,10 +1,10 @@ #![feature(rustc_attrs)] -extern +extern //~ WARN missing_abi "C"suffix //~ ERROR suffixes on string literals are invalid fn foo() {} -extern +extern //~ WARN missing_abi "C"suffix //~ ERROR suffixes on string literals are invalid {} diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index b5dacdf7d0d3d..121db2058f109 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -49,6 +49,20 @@ LL | #[rustc_layout_scalar_valid_range_start(0suffix)] | = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/bad-lit-suffixes.rs:3:1 + | +LL | extern + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/bad-lit-suffixes.rs:7:1 + | +LL | extern + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + error: suffixes on string literals are invalid --> $DIR/bad-lit-suffixes.rs:12:5 | @@ -149,5 +163,5 @@ LL | 1.0e10suffix; | = help: valid suffixes are `f32` and `f64` -error: aborting due to 21 previous errors +error: aborting due to 21 previous errors; 2 warnings emitted diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs index 34b687a0f5261..5ecf804de09fe 100644 --- a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs @@ -1,4 +1,5 @@ //@ edition:2018 +#![allow(missing_abi)] // There is an order to respect for keywords before a function: // `, const, async, unsafe, extern, ""` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr index 0e9f7c51e1a45..232da9acef309 100644 --- a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr @@ -1,5 +1,5 @@ error: expected `fn`, found keyword `unsafe` - --> $DIR/wrong-unsafe.rs:9:8 + --> $DIR/wrong-unsafe.rs:10:8 | LL | extern unsafe fn test() {} | -------^^^^^^ diff --git a/tests/ui/parser/item-kw-case-mismatch.fixed b/tests/ui/parser/item-kw-case-mismatch.fixed index f5afa482712f6..4ee8f9c19dc27 100644 --- a/tests/ui/parser/item-kw-case-mismatch.fixed +++ b/tests/ui/parser/item-kw-case-mismatch.fixed @@ -25,7 +25,7 @@ const unsafe fn _e() {} //~| ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `fn` is written in the wrong case -unsafe extern fn _f() {} +unsafe extern "C" fn _f() {} //~^ ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `extern` is written in the wrong case diff --git a/tests/ui/parser/item-kw-case-mismatch.rs b/tests/ui/parser/item-kw-case-mismatch.rs index ea224e08a0085..6c858b848cf2c 100644 --- a/tests/ui/parser/item-kw-case-mismatch.rs +++ b/tests/ui/parser/item-kw-case-mismatch.rs @@ -25,7 +25,7 @@ CONST UNSAFE FN _e() {} //~| ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `fn` is written in the wrong case -unSAFE EXTern fn _f() {} +unSAFE EXTern "C" fn _f() {} //~^ ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `extern` is written in the wrong case diff --git a/tests/ui/parser/item-kw-case-mismatch.stderr b/tests/ui/parser/item-kw-case-mismatch.stderr index 0abc59e064a00..36df72b5cad1c 100644 --- a/tests/ui/parser/item-kw-case-mismatch.stderr +++ b/tests/ui/parser/item-kw-case-mismatch.stderr @@ -111,23 +111,23 @@ LL | CONST UNSAFE fn _e() {} error: keyword `unsafe` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:28:1 | -LL | unSAFE EXTern fn _f() {} +LL | unSAFE EXTern "C" fn _f() {} | ^^^^^^ | help: write it in the correct case | -LL | unsafe EXTern fn _f() {} +LL | unsafe EXTern "C" fn _f() {} | ~~~~~~ error: keyword `extern` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:28:8 | -LL | unSAFE EXTern fn _f() {} +LL | unSAFE EXTern "C" fn _f() {} | ^^^^^^ | help: write it in the correct case | -LL | unSAFE extern fn _f() {} +LL | unSAFE extern "C" fn _f() {} | ~~~~~~ error: keyword `extern` is written in the wrong case diff --git a/tests/ui/parser/lit-err-in-macro.rs b/tests/ui/parser/lit-err-in-macro.rs index cff8ee6b40ca6..ca117ac4a15d4 100644 --- a/tests/ui/parser/lit-err-in-macro.rs +++ b/tests/ui/parser/lit-err-in-macro.rs @@ -1,6 +1,6 @@ macro_rules! f { ($abi:literal) => { - extern $abi fn f() {} + extern $abi fn f() {} //~ WARN missing_abi } } diff --git a/tests/ui/parser/lit-err-in-macro.stderr b/tests/ui/parser/lit-err-in-macro.stderr index 12e6d51906030..fc2603d0b104c 100644 --- a/tests/ui/parser/lit-err-in-macro.stderr +++ b/tests/ui/parser/lit-err-in-macro.stderr @@ -4,5 +4,17 @@ error: suffixes on string literals are invalid LL | f!("Foo"__); | ^^^^^^^ invalid suffix `__` -error: aborting due to 1 previous error +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/lit-err-in-macro.rs:3:9 + | +LL | extern $abi fn f() {} + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` +... +LL | f!("Foo"__); + | ----------- in this macro invocation + | + = note: `#[warn(missing_abi)]` on by default + = note: this warning originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/parser/recover/recover-const-async-fn-ptr.rs b/tests/ui/parser/recover/recover-const-async-fn-ptr.rs index 2d8a3858aa603..45d753495999b 100644 --- a/tests/ui/parser/recover/recover-const-async-fn-ptr.rs +++ b/tests/ui/parser/recover/recover-const-async-fn-ptr.rs @@ -2,9 +2,9 @@ type T0 = const fn(); //~ ERROR an `fn` pointer type cannot be `const` type T1 = const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -type T2 = const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +type T2 = const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` type T3 = async fn(); //~ ERROR an `fn` pointer type cannot be `async` -type T4 = async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +type T4 = async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type T5 = async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type T6 = const async unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `const` @@ -12,9 +12,9 @@ type T6 = const async unsafe extern "C" fn(); type FT0 = for<'a> const fn(); //~ ERROR an `fn` pointer type cannot be `const` type FT1 = for<'a> const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -type FT2 = for<'a> const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +type FT2 = for<'a> const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` type FT3 = for<'a> async fn(); //~ ERROR an `fn` pointer type cannot be `async` -type FT4 = for<'a> async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +type FT4 = for<'a> async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type FT5 = for<'a> async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type FT6 = for<'a> const async unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `const` diff --git a/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr b/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr index 8e5b76163ade1..9112a0e135a50 100644 --- a/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr +++ b/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr @@ -29,15 +29,15 @@ LL + type T1 = extern "C" fn(); error: an `fn` pointer type cannot be `const` --> $DIR/recover-const-async-fn-ptr.rs:5:11 | -LL | type T2 = const unsafe extern fn(); - | -----^^^^^^^^^^^^^^^^^^^ +LL | type T2 = const unsafe extern "C" fn(); + | -----^^^^^^^^^^^^^^^^^^^^^^^ | | | `const` because of this | help: remove the `const` qualifier | -LL - type T2 = const unsafe extern fn(); -LL + type T2 = unsafe extern fn(); +LL - type T2 = const unsafe extern "C" fn(); +LL + type T2 = unsafe extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -57,15 +57,15 @@ LL + type T3 = fn(); error: an `fn` pointer type cannot be `async` --> $DIR/recover-const-async-fn-ptr.rs:7:11 | -LL | type T4 = async extern fn(); - | -----^^^^^^^^^^^^ +LL | type T4 = async extern "C" fn(); + | -----^^^^^^^^^^^^^^^^ | | | `async` because of this | help: remove the `async` qualifier | -LL - type T4 = async extern fn(); -LL + type T4 = extern fn(); +LL - type T4 = async extern "C" fn(); +LL + type T4 = extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -141,15 +141,15 @@ LL + type FT1 = for<'a> extern "C" fn(); error: an `fn` pointer type cannot be `const` --> $DIR/recover-const-async-fn-ptr.rs:15:12 | -LL | type FT2 = for<'a> const unsafe extern fn(); - | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^ +LL | type FT2 = for<'a> const unsafe extern "C" fn(); + | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^ | | | `const` because of this | help: remove the `const` qualifier | -LL - type FT2 = for<'a> const unsafe extern fn(); -LL + type FT2 = for<'a> unsafe extern fn(); +LL - type FT2 = for<'a> const unsafe extern "C" fn(); +LL + type FT2 = for<'a> unsafe extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -169,15 +169,15 @@ LL + type FT3 = for<'a> fn(); error: an `fn` pointer type cannot be `async` --> $DIR/recover-const-async-fn-ptr.rs:17:12 | -LL | type FT4 = for<'a> async extern fn(); - | ^^^^^^^^-----^^^^^^^^^^^^ +LL | type FT4 = for<'a> async extern "C" fn(); + | ^^^^^^^^-----^^^^^^^^^^^^^^^^ | | | `async` because of this | help: remove the `async` qualifier | -LL - type FT4 = for<'a> async extern fn(); -LL + type FT4 = for<'a> extern fn(); +LL - type FT4 = for<'a> async extern "C" fn(); +LL + type FT4 = for<'a> extern "C" fn(); | error: an `fn` pointer type cannot be `async` diff --git a/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs b/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs index 76c56a715d2a4..ab2cfc961dff1 100644 --- a/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs +++ b/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs @@ -19,7 +19,7 @@ fn main() { type Hmm = fn<>(); //~^ ERROR function pointer types may not have generic parameters - let _: extern fn<'a: 'static>(); + let _: extern "C" fn<'a: 'static>(); //~^ ERROR function pointer types may not have generic parameters //~| ERROR bounds cannot be used in this context diff --git a/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr b/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr index 6b6cb2d6bdde7..9023856ef2486 100644 --- a/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr +++ b/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr @@ -59,15 +59,15 @@ LL | type Hmm = fn<>(); | ^^ error: function pointer types may not have generic parameters - --> $DIR/recover-fn-ptr-with-generics.rs:22:21 + --> $DIR/recover-fn-ptr-with-generics.rs:22:25 | -LL | let _: extern fn<'a: 'static>(); - | ^^^^^^^^^^^^^ +LL | let _: extern "C" fn<'a: 'static>(); + | ^^^^^^^^^^^^^ | help: consider moving the lifetime parameter to a `for` parameter list | -LL - let _: extern fn<'a: 'static>(); -LL + let _: for<'a> extern fn(); +LL - let _: extern "C" fn<'a: 'static>(); +LL + let _: for<'a> extern "C" fn(); | error: function pointer types may not have generic parameters @@ -101,10 +101,10 @@ LL | type Identity = fn(T) -> T; | ^ not found in this scope error: bounds cannot be used in this context - --> $DIR/recover-fn-ptr-with-generics.rs:22:26 + --> $DIR/recover-fn-ptr-with-generics.rs:22:30 | -LL | let _: extern fn<'a: 'static>(); - | ^^^^^^^ +LL | let _: extern "C" fn<'a: 'static>(); + | ^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/parser/recover/recover-missing-semi-before-item.fixed b/tests/ui/parser/recover/recover-missing-semi-before-item.fixed index 6f85452c6fb96..871fa0d24eca7 100644 --- a/tests/ui/parser/recover/recover-missing-semi-before-item.fixed +++ b/tests/ui/parser/recover/recover-missing-semi-before-item.fixed @@ -28,7 +28,7 @@ fn for_fn() { fn for_extern() { let foo = 3; //~ ERROR expected `;`, found keyword `extern` - extern fn foo() {} + extern "C" fn foo() {} } fn for_impl() { diff --git a/tests/ui/parser/recover/recover-missing-semi-before-item.rs b/tests/ui/parser/recover/recover-missing-semi-before-item.rs index f75945b55c2b0..de92603a74c68 100644 --- a/tests/ui/parser/recover/recover-missing-semi-before-item.rs +++ b/tests/ui/parser/recover/recover-missing-semi-before-item.rs @@ -28,7 +28,7 @@ fn for_fn() { fn for_extern() { let foo = 3 //~ ERROR expected `;`, found keyword `extern` - extern fn foo() {} + extern "C" fn foo() {} } fn for_impl() { diff --git a/tests/ui/parser/recover/recover-missing-semi-before-item.stderr b/tests/ui/parser/recover/recover-missing-semi-before-item.stderr index 61c43f2f18998..3b55cd9ddd086 100644 --- a/tests/ui/parser/recover/recover-missing-semi-before-item.stderr +++ b/tests/ui/parser/recover/recover-missing-semi-before-item.stderr @@ -35,7 +35,7 @@ error: expected `;`, found keyword `extern` | LL | let foo = 3 | ^ help: add `;` here -LL | extern fn foo() {} +LL | extern "C" fn foo() {} | ------ unexpected token error: expected `;`, found keyword `impl` diff --git a/tests/ui/proc-macro/inner-attrs.stderr b/tests/ui/proc-macro/inner-attrs.stderr index ee8732c650dc9..3ab180be821a9 100644 --- a/tests/ui/proc-macro/inner-attrs.stderr +++ b/tests/ui/proc-macro/inner-attrs.stderr @@ -22,5 +22,13 @@ error: expected non-macro inner attribute, found attribute macro `print_attr` LL | #![print_attr] | ^^^^^^^^^^ not a non-macro inner attribute -error: aborting due to 4 previous errors +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/inner-attrs.rs:82:1 + | +LL | extern { + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + +error: aborting due to 4 previous errors; 1 warning emitted diff --git a/tests/ui/proc-macro/issue-66286.rs b/tests/ui/proc-macro/issue-66286.rs index 3ca064768b2d6..9e7719c98367f 100644 --- a/tests/ui/proc-macro/issue-66286.rs +++ b/tests/ui/proc-macro/issue-66286.rs @@ -5,7 +5,7 @@ extern crate issue_66286; #[issue_66286::vec_ice] -pub extern fn foo(_: Vec(u32)) -> u32 { +pub extern "C" fn foo(_: Vec(u32)) -> u32 { //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait 0 } diff --git a/tests/ui/proc-macro/issue-66286.stderr b/tests/ui/proc-macro/issue-66286.stderr index fc4c2062fd7bc..c92bed1b56344 100644 --- a/tests/ui/proc-macro/issue-66286.stderr +++ b/tests/ui/proc-macro/issue-66286.stderr @@ -1,13 +1,13 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-66286.rs:8:22 + --> $DIR/issue-66286.rs:8:26 | -LL | pub extern fn foo(_: Vec(u32)) -> u32 { - | ^^^^^^^^ only `Fn` traits may use parentheses +LL | pub extern "C" fn foo(_: Vec(u32)) -> u32 { + | ^^^^^^^^ only `Fn` traits may use parentheses | help: use angle brackets instead | -LL | pub extern fn foo(_: Vec) -> u32 { - | ~ ~ +LL | pub extern "C" fn foo(_: Vec) -> u32 { + | ~ ~ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs index f33a3d62e2688..5982c771033d0 100644 --- a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs @@ -11,7 +11,7 @@ fn test() {} static mut imported_val: i32 = 123; #[link(name = "exporter", kind = "raw-dylib")] -extern { +extern "C" { #[link_ordinal(13)] fn imported_function(); diff --git a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.fixed b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.fixed index 586881d180767..8b179f7ef933e 100644 --- a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.fixed +++ b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.fixed @@ -4,7 +4,7 @@ macro_rules! tt { ($e:tt) => { #$e - extern fn foo() {} + extern "C" fn foo() {} } } @@ -13,7 +13,7 @@ macro_rules! ident { #[unsafe($e)] //~^ ERROR: unsafe attribute used without unsafe //~| WARN this is accepted in the current edition - extern fn bar() {} + extern "C" fn bar() {} } } @@ -22,21 +22,21 @@ macro_rules! ident2 { #[unsafe($e = $l)] //~^ ERROR: unsafe attribute used without unsafe //~| WARN this is accepted in the current edition - extern fn bars() {} + extern "C" fn bars() {} } } macro_rules! meta { ($m:meta) => { #[$m] - extern fn baz() {} + extern "C" fn baz() {} } } macro_rules! meta2 { ($m:meta) => { #[$m] - extern fn baw() {} + extern "C" fn baw() {} } } diff --git a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.rs b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.rs index 03e122c7d57e7..34e5a6b96e389 100644 --- a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.rs +++ b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.rs @@ -4,7 +4,7 @@ macro_rules! tt { ($e:tt) => { #$e - extern fn foo() {} + extern "C" fn foo() {} } } @@ -13,7 +13,7 @@ macro_rules! ident { #[$e] //~^ ERROR: unsafe attribute used without unsafe //~| WARN this is accepted in the current edition - extern fn bar() {} + extern "C" fn bar() {} } } @@ -22,21 +22,21 @@ macro_rules! ident2 { #[$e = $l] //~^ ERROR: unsafe attribute used without unsafe //~| WARN this is accepted in the current edition - extern fn bars() {} + extern "C" fn bars() {} } } macro_rules! meta { ($m:meta) => { #[$m] - extern fn baz() {} + extern "C" fn baz() {} } } macro_rules! meta2 { ($m:meta) => { #[$m] - extern fn baw() {} + extern "C" fn baw() {} } } diff --git a/tests/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs b/tests/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs index a969295c9f9cd..65c57c42530a1 100644 --- a/tests/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs +++ b/tests/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs @@ -6,7 +6,7 @@ use std::ptr::NonNull; -extern { +extern "C" { type Extern; } diff --git a/tests/ui/statics/uninhabited-static.rs b/tests/ui/statics/uninhabited-static.rs index a0f83f450792a..0f7c5ae6ef4a3 100644 --- a/tests/ui/statics/uninhabited-static.rs +++ b/tests/ui/statics/uninhabited-static.rs @@ -2,7 +2,7 @@ #![deny(uninhabited_static)] enum Void {} -extern { +extern "C" { static VOID: Void; //~ ERROR static of uninhabited type //~| WARN: previously accepted static NEVER: !; //~ ERROR static of uninhabited type diff --git a/tests/ui/unpretty/expanded-exhaustive.rs b/tests/ui/unpretty/expanded-exhaustive.rs index 799e8071d028a..39ee25934c99e 100644 --- a/tests/ui/unpretty/expanded-exhaustive.rs +++ b/tests/ui/unpretty/expanded-exhaustive.rs @@ -452,15 +452,15 @@ mod items { /// ItemKind::Fn mod item_fn { pub const unsafe extern "C" fn f() {} - pub async unsafe extern fn g() {} + pub async unsafe extern "C" fn g() {} fn h<'a, T>() where T: 'a {} trait TraitItems { - unsafe extern fn f(); + unsafe extern "C" fn f(); } impl TraitItems for _ { - default unsafe extern fn f() {} + default unsafe extern "C" fn f() {} } } @@ -472,7 +472,7 @@ mod items { /// ItemKind::ForeignMod mod item_foreign_mod { unsafe extern "C++" {} - unsafe extern {} + unsafe extern "C" {} } /// ItemKind::GlobalAsm diff --git a/tests/ui/unpretty/expanded-exhaustive.stdout b/tests/ui/unpretty/expanded-exhaustive.stdout index d8384951e12f0..34b55368fbdef 100644 --- a/tests/ui/unpretty/expanded-exhaustive.stdout +++ b/tests/ui/unpretty/expanded-exhaustive.stdout @@ -433,13 +433,13 @@ mod items { /// ItemKind::Fn mod item_fn { pub const unsafe extern "C" fn f() {} - pub async unsafe extern fn g() {} + pub async unsafe extern "C" fn g() {} fn h<'a, T>() where T: 'a {} trait TraitItems { - unsafe extern fn f(); + unsafe extern "C" fn f(); } impl TraitItems for _ { - default unsafe extern fn f() {} + default unsafe extern "C" fn f() {} } } /// ItemKind::Mod @@ -447,7 +447,7 @@ mod items { /// ItemKind::ForeignMod mod item_foreign_mod { unsafe extern "C++" {} - unsafe extern {} + unsafe extern "C" {} } /// ItemKind::GlobalAsm mod item_global_asm {