From a528f4ecd99cd5e1fb4454fc383688eccd4e34e1 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Thu, 29 Aug 2024 15:33:34 +0200 Subject: [PATCH] stabilize `const_extern_fn` --- compiler/rustc_ast_passes/src/feature_gate.rs | 25 ++--- compiler/rustc_feature/src/accepted.rs | 2 + compiler/rustc_feature/src/unstable.rs | 2 - compiler/rustc_parse/src/parser/ty.rs | 3 - src/tools/clippy/clippy_config/src/msrvs.rs | 3 +- .../clippy_lints/src/missing_const_for_fn.rs | 10 +- .../ui/missing_const_for_fn/cant_be_const.rs | 6 -- .../missing_const_for_fn/could_be_const.fixed | 14 +++ .../ui/missing_const_for_fn/could_be_const.rs | 14 +++ .../could_be_const.stderr | 99 ++++++++++++++----- .../could_be_const_with_const_extern_fn.fixed | 14 --- .../could_be_const_with_const_extern_fn.rs | 14 --- ...could_be_const_with_const_extern_fn.stderr | 59 ----------- tests/ui/consts/const-eval/unwind-abort.rs | 2 - .../ui/consts/const-eval/unwind-abort.stderr | 8 +- .../const-extern-fn-call-extern-fn.rs | 2 - .../const-extern-fn-call-extern-fn.stderr | 4 +- .../const-extern-fn-min-const-fn.rs | 9 +- .../const-extern-fn-min-const-fn.stderr | 6 +- .../const-extern-fn-requires-unsafe.rs | 10 +- .../const-extern-fn-requires-unsafe.stderr | 22 ++++- .../consts/const-extern-fn/const-extern-fn.rs | 9 +- .../feature-gate-const_extern_fn.rs | 13 --- .../feature-gate-const_extern_fn.stderr | 23 ----- .../ui/consts/miri_unleashed/abi-mismatch.rs | 2 - .../consts/miri_unleashed/abi-mismatch.stderr | 8 +- tests/ui/consts/unwind-abort.rs | 2 - tests/ui/parser/fn-header-semantic-fail.rs | 2 - .../ui/parser/fn-header-semantic-fail.stderr | 34 +++---- 29 files changed, 186 insertions(+), 235 deletions(-) delete mode 100644 src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.fixed delete mode 100644 src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs delete mode 100644 src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.stderr delete mode 100644 tests/ui/consts/const-extern-fn/feature-gate-const_extern_fn.rs delete mode 100644 tests/ui/consts/const-extern-fn/feature-gate-const_extern_fn.stderr diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 45e397a58c0..cfc534acd98 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -75,22 +75,9 @@ struct PostExpansionVisitor<'a> { impl<'a> PostExpansionVisitor<'a> { #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable - fn check_abi(&self, abi: ast::StrLit, constness: ast::Const) { + fn check_abi(&self, abi: ast::StrLit) { let ast::StrLit { symbol_unescaped, span, .. } = abi; - if let ast::Const::Yes(_) = constness { - match symbol_unescaped { - // Stable - sym::Rust | sym::C => {} - abi => gate!( - &self, - const_extern_fn, - span, - format!("`{}` as a `const fn` ABI is unstable", abi) - ), - } - } - match abi::is_enabled(self.features, span, symbol_unescaped.as_str()) { Ok(()) => (), Err(abi::AbiDisabled::Unstable { feature, explain }) => { @@ -110,9 +97,9 @@ impl<'a> PostExpansionVisitor<'a> { } } - fn check_extern(&self, ext: ast::Extern, constness: ast::Const) { + fn check_extern(&self, ext: ast::Extern) { if let ast::Extern::Explicit(abi, _) = ext { - self.check_abi(abi, constness); + self.check_abi(abi); } } @@ -239,7 +226,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { match &i.kind { ast::ItemKind::ForeignMod(foreign_module) => { if let Some(abi) = foreign_module.abi { - self.check_abi(abi, ast::Const::No); + self.check_abi(abi); } } @@ -341,7 +328,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { match &ty.kind { ast::TyKind::BareFn(bare_fn_ty) => { // Function pointers cannot be `const` - self.check_extern(bare_fn_ty.ext, ast::Const::No); + self.check_extern(bare_fn_ty.ext); self.check_late_bound_lifetime_defs(&bare_fn_ty.generic_params); } ast::TyKind::Never => { @@ -446,7 +433,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_fn(&mut self, fn_kind: FnKind<'a>, span: Span, _: NodeId) { if let Some(header) = fn_kind.header() { // Stability of const fn methods are covered in `visit_assoc_item` below. - self.check_extern(header.ext, header.constness); + self.check_extern(header.ext); } if let FnKind::Closure(ast::ClosureBinder::For { generic_params, .. }, ..) = fn_kind { diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index 8949fdffdae..468ea81524a 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -115,6 +115,8 @@ declare_features! ( (accepted, conservative_impl_trait, "1.26.0", Some(34511)), /// Allows calling constructor functions in `const fn`. (accepted, const_constructor, "1.40.0", Some(61456)), + /// Allows the definition of `const extern fn` and `const unsafe extern fn`. + (accepted, const_extern_fn, "CURRENT_RUSTC_VERSION", Some(64926)), /// Allows basic arithmetic on floating point types in a `const fn`. (accepted, const_fn_floating_point_arithmetic, "1.82.0", Some(57241)), /// Allows using and casting function pointers in a `const fn`. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 6ed5ea9f8bb..05856dca491 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -401,8 +401,6 @@ declare_features! ( (unstable, const_async_blocks, "1.53.0", Some(85368)), /// Allows `const || {}` closures in const contexts. (incomplete, const_closures, "1.68.0", Some(106003)), - /// Allows the definition of `const extern fn` and `const unsafe extern fn`. - (unstable, const_extern_fn, "1.40.0", Some(64926)), /// Allows `for _ in _` loops in const contexts. (unstable, const_for, "1.56.0", Some(87575)), /// Allows using `&mut` in constant functions. diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index dd1cc75c7ff..66019ffbc0a 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -607,9 +607,6 @@ impl<'a> Parser<'a> { let decl = self.parse_fn_decl(|_| false, AllowPlus::No, recover_return_sign)?; let whole_span = lo.to(self.prev_token.span); if let ast::Const::Yes(span) = constness { - // If we ever start to allow `const fn()`, then update - // feature gating for `#![feature(const_extern_fn)]` to - // cover it. self.dcx().emit_err(FnPointerCannotBeConst { span: whole_span, qualifier: span }); } if let Some(ast::CoroutineKind::Async { span, .. }) = coroutine_kind { diff --git a/src/tools/clippy/clippy_config/src/msrvs.rs b/src/tools/clippy/clippy_config/src/msrvs.rs index e17458b3310..a2b4b6e256f 100644 --- a/src/tools/clippy/clippy_config/src/msrvs.rs +++ b/src/tools/clippy/clippy_config/src/msrvs.rs @@ -17,6 +17,7 @@ macro_rules! msrv_aliases { // names may refer to stabilized feature flags or library items msrv_aliases! { + 1,83,0 { CONST_EXTERN_FN } 1,83,0 { CONST_FLOAT_BITS_CONV } 1,81,0 { LINT_REASONS_STABILIZATION } 1,80,0 { BOX_INTO_ITER} @@ -27,7 +28,7 @@ msrv_aliases! { 1,68,0 { PATH_MAIN_SEPARATOR_STR } 1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS } 1,63,0 { CLONE_INTO } - 1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE, CONST_EXTERN_FN } + 1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE, CONST_EXTERN_C_FN } 1,59,0 { THREAD_LOCAL_CONST_INIT } 1,58,0 { FORMAT_ARGS_CAPTURE, PATTERN_TRAIT_CHAR_ARRAY, CONST_RAW_PTR_DEREF } 1,56,0 { CONST_FN_UNION } diff --git a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs index 052d738b2e7..859afe1b963 100644 --- a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs +++ b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs @@ -119,9 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn { .iter() .any(|param| matches!(param.kind, GenericParamKind::Const { .. })); - if already_const(header) - || has_const_generic_params - || !could_be_const_with_abi(cx, &self.msrv, header.abi) + if already_const(header) || has_const_generic_params || !could_be_const_with_abi(&self.msrv, header.abi) { return; } @@ -183,13 +181,13 @@ fn already_const(header: hir::FnHeader) -> bool { header.constness == Constness::Const } -fn could_be_const_with_abi(cx: &LateContext<'_>, msrv: &Msrv, abi: Abi) -> bool { +fn could_be_const_with_abi(msrv: &Msrv, abi: Abi) -> bool { match abi { Abi::Rust => true, // `const extern "C"` was stabilized after 1.62.0 - Abi::C { unwind: false } => msrv.meets(msrvs::CONST_EXTERN_FN), + Abi::C { unwind: false } => msrv.meets(msrvs::CONST_EXTERN_C_FN), // Rest ABIs are still unstable and need the `const_extern_fn` feature enabled. - _ => cx.tcx.features().const_extern_fn, + _ => msrv.meets(msrvs::CONST_EXTERN_FN), } } diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/cant_be_const.rs b/src/tools/clippy/tests/ui/missing_const_for_fn/cant_be_const.rs index 2c6e1e92da0..ca323dcf173 100644 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/cant_be_const.rs +++ b/src/tools/clippy/tests/ui/missing_const_for_fn/cant_be_const.rs @@ -186,12 +186,6 @@ mod msrv { extern "C" fn c() {} } -mod with_extern { - extern "C-unwind" fn c_unwind() {} - extern "system" fn system() {} - extern "system-unwind" fn system_unwind() {} -} - mod with_ty_alias { type Foo = impl std::fmt::Debug; 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 f54503ada97..0aef4d31fd9 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 @@ -1,5 +1,6 @@ #![warn(clippy::missing_const_for_fn)] #![allow(incomplete_features, clippy::let_and_return, clippy::missing_transmute_annotations)] +#![allow(unsupported_calling_conventions)] #![feature(const_mut_refs)] #![feature(const_trait_impl)] @@ -204,3 +205,16 @@ mod with_ty_alias { // in this test. const fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {} } + +mod extern_fn { + const extern "C-unwind" fn c_unwind() {} + //~^ ERROR: this could be a `const fn` + const extern "system" fn system() {} + //~^ ERROR: this could be a `const fn` + const extern "system-unwind" fn system_unwind() {} + //~^ ERROR: this could be a `const fn` + pub const extern "stdcall" fn std_call() {} + //~^ ERROR: this could be a `const fn` + pub const extern "stdcall-unwind" fn std_call_unwind() {} + //~^ 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 2c229068e4d..4246494fe72 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 @@ -1,5 +1,6 @@ #![warn(clippy::missing_const_for_fn)] #![allow(incomplete_features, clippy::let_and_return, clippy::missing_transmute_annotations)] +#![allow(unsupported_calling_conventions)] #![feature(const_mut_refs)] #![feature(const_trait_impl)] @@ -204,3 +205,16 @@ mod with_ty_alias { // in this test. fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {} } + +mod extern_fn { + extern "C-unwind" fn c_unwind() {} + //~^ ERROR: this could be a `const fn` + extern "system" fn system() {} + //~^ ERROR: this could be a `const fn` + extern "system-unwind" fn system_unwind() {} + //~^ ERROR: this could be a `const fn` + pub extern "stdcall" fn std_call() {} + //~^ ERROR: this could be a `const fn` + pub extern "stdcall-unwind" fn std_call_unwind() {} + //~^ 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 fb4db703103..6bc71e29840 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 @@ -1,5 +1,5 @@ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:14:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:15:5 | LL | / pub fn new() -> Self { LL | | @@ -16,7 +16,7 @@ LL | pub const fn new() -> Self { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:20:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:21:5 | LL | / fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] { LL | | @@ -30,7 +30,7 @@ LL | const fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:27:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:28:1 | LL | / fn one() -> i32 { LL | | @@ -44,7 +44,7 @@ LL | const fn one() -> i32 { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:33:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:34:1 | LL | / fn two() -> i32 { LL | | @@ -59,7 +59,7 @@ LL | const fn two() -> i32 { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:40:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:41:1 | LL | / fn string() -> String { LL | | @@ -73,7 +73,7 @@ LL | const fn string() -> String { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:46:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:47:1 | LL | / unsafe fn four() -> i32 { LL | | @@ -87,7 +87,7 @@ LL | const unsafe fn four() -> i32 { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:52:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:53:1 | LL | / fn generic(t: T) -> T { LL | | @@ -101,7 +101,7 @@ LL | const fn generic(t: T) -> T { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:61:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:62:1 | LL | / fn generic_arr(t: [T; 1]) -> T { LL | | @@ -115,7 +115,7 @@ LL | const fn generic_arr(t: [T; 1]) -> T { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:75:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:76:9 | LL | / pub fn b(self, a: &A) -> B { LL | | @@ -129,7 +129,7 @@ LL | pub const fn b(self, a: &A) -> B { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:85:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:86:5 | LL | / fn const_fn_stabilized_before_msrv(byte: u8) { LL | | @@ -143,7 +143,7 @@ LL | const fn const_fn_stabilized_before_msrv(byte: u8) { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:97:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:98:1 | LL | / fn msrv_1_46() -> i32 { LL | | @@ -157,7 +157,7 @@ LL | const fn msrv_1_46() -> i32 { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:117:1 + --> tests/ui/missing_const_for_fn/could_be_const.rs:118:1 | LL | fn d(this: D) {} | ^^^^^^^^^^^^^^^^ @@ -168,7 +168,7 @@ LL | const fn d(this: D) {} | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:125:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:126:9 | LL | / fn deref_ptr_can_be_const(self) -> usize { LL | | @@ -182,7 +182,7 @@ LL | const fn deref_ptr_can_be_const(self) -> usize { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:130:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:131:9 | LL | / fn deref_copied_val(self) -> usize { LL | | @@ -196,7 +196,7 @@ LL | const fn deref_copied_val(self) -> usize { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:141:5 + --> tests/ui/missing_const_for_fn/could_be_const.rs:142:5 | LL | / fn union_access_can_be_const() { LL | | @@ -211,7 +211,7 @@ LL | const fn union_access_can_be_const() { | +++++ error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const.rs:149:9 + --> tests/ui/missing_const_for_fn/could_be_const.rs:150:9 | LL | extern "C" fn c() {} | ^^^^^^^^^^^^^^^^^^^^ @@ -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) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -283,5 +283,60 @@ help: make the function `const` LL | const fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {} | +++++ -error: aborting due to 21 previous errors +error: this could be a `const fn` + --> tests/ui/missing_const_for_fn/could_be_const.rs:210:5 + | +LL | extern "C-unwind" fn c_unwind() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: make the function `const` + | +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:212:5 + | +LL | extern "system" fn system() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: make the function `const` + | +LL | const extern "system" fn system() {} + | +++++ + +error: this could be a `const fn` + --> tests/ui/missing_const_for_fn/could_be_const.rs:214:5 + | +LL | extern "system-unwind" fn system_unwind() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: make the function `const` + | +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:216:5 + | +LL | pub extern "stdcall" fn std_call() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: make the function `const` + | +LL | pub const extern "stdcall" fn std_call() {} + | +++++ + +error: this could be a `const fn` + --> tests/ui/missing_const_for_fn/could_be_const.rs:218:5 + | +LL | pub extern "stdcall-unwind" fn std_call_unwind() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: make the function `const` + | +LL | pub const extern "stdcall-unwind" fn std_call_unwind() {} + | +++++ + +error: aborting due to 26 previous errors diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.fixed b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.fixed deleted file mode 100644 index c103db536ab..00000000000 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.fixed +++ /dev/null @@ -1,14 +0,0 @@ -#![warn(clippy::missing_const_for_fn)] -#![allow(unsupported_calling_conventions)] -#![feature(const_extern_fn)] - -const extern "C-unwind" fn c_unwind() {} -//~^ ERROR: this could be a `const fn` -const extern "system" fn system() {} -//~^ ERROR: this could be a `const fn` -const extern "system-unwind" fn system_unwind() {} -//~^ ERROR: this could be a `const fn` -pub const extern "stdcall" fn std_call() {} -//~^ ERROR: this could be a `const fn` -pub const extern "stdcall-unwind" fn std_call_unwind() {} -//~^ ERROR: this could be a `const fn` diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs deleted file mode 100644 index 0f7020ae559..00000000000 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![warn(clippy::missing_const_for_fn)] -#![allow(unsupported_calling_conventions)] -#![feature(const_extern_fn)] - -extern "C-unwind" fn c_unwind() {} -//~^ ERROR: this could be a `const fn` -extern "system" fn system() {} -//~^ ERROR: this could be a `const fn` -extern "system-unwind" fn system_unwind() {} -//~^ ERROR: this could be a `const fn` -pub extern "stdcall" fn std_call() {} -//~^ ERROR: this could be a `const fn` -pub extern "stdcall-unwind" fn std_call_unwind() {} -//~^ ERROR: this could be a `const fn` diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.stderr b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.stderr deleted file mode 100644 index 036094a367b..00000000000 --- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.stderr +++ /dev/null @@ -1,59 +0,0 @@ -error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:5:1 - | -LL | extern "C-unwind" fn c_unwind() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D clippy::missing-const-for-fn` implied by `-D warnings` - = help: to override `-D warnings` add `#[allow(clippy::missing_const_for_fn)]` -help: make the function `const` - | -LL | const extern "C-unwind" fn c_unwind() {} - | +++++ - -error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:7:1 - | -LL | extern "system" fn system() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: make the function `const` - | -LL | const extern "system" fn system() {} - | +++++ - -error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:9:1 - | -LL | extern "system-unwind" fn system_unwind() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: make the function `const` - | -LL | const extern "system-unwind" fn system_unwind() {} - | +++++ - -error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:11:1 - | -LL | pub extern "stdcall" fn std_call() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: make the function `const` - | -LL | pub const extern "stdcall" fn std_call() {} - | +++++ - -error: this could be a `const fn` - --> tests/ui/missing_const_for_fn/could_be_const_with_const_extern_fn.rs:13:1 - | -LL | pub extern "stdcall-unwind" fn std_call_unwind() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: make the function `const` - | -LL | pub const extern "stdcall-unwind" fn std_call_unwind() {} - | +++++ - -error: aborting due to 5 previous errors - diff --git a/tests/ui/consts/const-eval/unwind-abort.rs b/tests/ui/consts/const-eval/unwind-abort.rs index 26113e23888..8d5ed876e43 100644 --- a/tests/ui/consts/const-eval/unwind-abort.rs +++ b/tests/ui/consts/const-eval/unwind-abort.rs @@ -1,5 +1,3 @@ -#![feature(const_extern_fn)] - const extern "C" fn foo() { panic!() //~ ERROR evaluation of constant value failed } diff --git a/tests/ui/consts/const-eval/unwind-abort.stderr b/tests/ui/consts/const-eval/unwind-abort.stderr index d7330beca7b..340f1dbe841 100644 --- a/tests/ui/consts/const-eval/unwind-abort.stderr +++ b/tests/ui/consts/const-eval/unwind-abort.stderr @@ -1,16 +1,16 @@ error[E0080]: evaluation of constant value failed - --> $DIR/unwind-abort.rs:4:5 + --> $DIR/unwind-abort.rs:2:5 | LL | panic!() - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:4:5 + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:2:5 | note: inside `foo` - --> $DIR/unwind-abort.rs:4:5 + --> $DIR/unwind-abort.rs:2:5 | LL | panic!() | ^^^^^^^^ note: inside `_` - --> $DIR/unwind-abort.rs:7:15 + --> $DIR/unwind-abort.rs:5:15 | LL | const _: () = foo(); | ^^^^^ diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs index eccda49db3e..31c15400f84 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.rs @@ -1,5 +1,3 @@ -#![feature(const_extern_fn)] - extern "C" { fn regular_in_block(); } diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr index 5acf22e4bc6..5d37f524e03 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-call-extern-fn.stderr @@ -1,5 +1,5 @@ error[E0015]: cannot call non-const fn `regular_in_block` in constant functions - --> $DIR/const-extern-fn-call-extern-fn.rs:9:9 + --> $DIR/const-extern-fn-call-extern-fn.rs:7:9 | LL | regular_in_block(); | ^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | regular_in_block(); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const fn `regular` in constant functions - --> $DIR/const-extern-fn-call-extern-fn.rs:18:9 + --> $DIR/const-extern-fn-call-extern-fn.rs:16:9 | LL | regular(); | ^^^^^^^^^ diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs b/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs index efc0a1c2fba..73b6dd51db7 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs @@ -1,7 +1,6 @@ -#![feature(const_extern_fn)] - -const extern "C" fn ptr_cast(val: *const u8) { val as usize; } -//~^ ERROR pointers cannot be cast to integers - +const extern "C" fn ptr_cast(val: *const u8) { + val as usize; + //~^ ERROR pointers cannot be cast to integers +} fn main() {} diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr b/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr index 9cdeec159be..7c21b1b606e 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr @@ -1,8 +1,8 @@ error: pointers cannot be cast to integers during const eval - --> $DIR/const-extern-fn-min-const-fn.rs:3:48 + --> $DIR/const-extern-fn-min-const-fn.rs:2:5 | -LL | const extern "C" fn ptr_cast(val: *const u8) { val as usize; } - | ^^^^^^^^^^^^ +LL | val as usize; + | ^^^^^^^^^^^^ | = note: at compile-time, pointers do not have an integer value = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs b/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs index 95fb9ef4260..a77ee293820 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs @@ -1,12 +1,18 @@ -#![feature(const_extern_fn)] - const unsafe extern "C" fn foo() -> usize { 5 } +const unsafe extern "C-unwind" fn bar() -> usize { + 5 +} + fn main() { let a: [u8; foo()]; //~^ call to unsafe function `foo` is unsafe and requires unsafe function or block foo(); //~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block + let b: [u8; bar()]; + //~^ call to unsafe function `bar` is unsafe and requires unsafe function or block + bar(); + //~^ ERROR call to unsafe function `bar` is unsafe and requires unsafe function or block } diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr b/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr index 6f59b2f2055..b4c779d59de 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr +++ b/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr @@ -1,19 +1,35 @@ error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block - --> $DIR/const-extern-fn-requires-unsafe.rs:10:5 + --> $DIR/const-extern-fn-requires-unsafe.rs:12:5 | LL | foo(); | ^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior +error[E0133]: call to unsafe function `bar` is unsafe and requires unsafe function or block + --> $DIR/const-extern-fn-requires-unsafe.rs:16:5 + | +LL | bar(); + | ^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block - --> $DIR/const-extern-fn-requires-unsafe.rs:8:17 + --> $DIR/const-extern-fn-requires-unsafe.rs:10:17 | LL | let a: [u8; foo()]; | ^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior -error: aborting due to 2 previous errors +error[E0133]: call to unsafe function `bar` is unsafe and requires unsafe function or block + --> $DIR/const-extern-fn-requires-unsafe.rs:14:17 + | +LL | let b: [u8; bar()]; + | ^^^^^ call to unsafe function + | + = note: consult the function's documentation for information on how to avoid undefined behavior + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/consts/const-extern-fn/const-extern-fn.rs b/tests/ui/consts/const-extern-fn/const-extern-fn.rs index 4b164767064..75ffa783a11 100644 --- a/tests/ui/consts/const-extern-fn/const-extern-fn.rs +++ b/tests/ui/consts/const-extern-fn/const-extern-fn.rs @@ -1,5 +1,4 @@ //@ run-pass -#![feature(const_extern_fn)] const extern "C" fn foo1(val: u8) -> u8 { val + 1 @@ -47,6 +46,10 @@ fn main() { let _bar2_cast: unsafe extern "C" fn(bool) -> bool = bar2; unsize(&[0, 1, 2]); - unsafe { closure(); } - unsafe { use_float(); } + unsafe { + closure(); + } + unsafe { + use_float(); + } } diff --git a/tests/ui/consts/const-extern-fn/feature-gate-const_extern_fn.rs b/tests/ui/consts/const-extern-fn/feature-gate-const_extern_fn.rs deleted file mode 100644 index f7bed91b037..00000000000 --- a/tests/ui/consts/const-extern-fn/feature-gate-const_extern_fn.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Check that `const extern fn` and `const unsafe extern fn` are feature-gated -// for certain ABIs. - -const extern fn foo1() {} -const extern "C" fn foo2() {} -const extern "Rust" fn foo3() {} -const extern "cdecl" fn foo4() {} //~ ERROR `cdecl` as a `const fn` ABI is unstable -const unsafe extern fn bar1() {} -const unsafe extern "C" fn bar2() {} -const unsafe extern "Rust" fn bar3() {} -const unsafe extern "cdecl" fn bar4() {} //~ ERROR `cdecl` as a `const fn` ABI is unstable - -fn main() {} diff --git a/tests/ui/consts/const-extern-fn/feature-gate-const_extern_fn.stderr b/tests/ui/consts/const-extern-fn/feature-gate-const_extern_fn.stderr deleted file mode 100644 index 81fb62e10a7..00000000000 --- a/tests/ui/consts/const-extern-fn/feature-gate-const_extern_fn.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: `cdecl` as a `const fn` ABI is unstable - --> $DIR/feature-gate-const_extern_fn.rs:7:14 - | -LL | const extern "cdecl" fn foo4() {} - | ^^^^^^^ - | - = note: see issue #64926 for more information - = help: add `#![feature(const_extern_fn)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `cdecl` as a `const fn` ABI is unstable - --> $DIR/feature-gate-const_extern_fn.rs:11:21 - | -LL | const unsafe extern "cdecl" fn bar4() {} - | ^^^^^^^ - | - = note: see issue #64926 for more information - = help: add `#![feature(const_extern_fn)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.rs b/tests/ui/consts/miri_unleashed/abi-mismatch.rs index 57680479a17..da5b1dd5802 100644 --- a/tests/ui/consts/miri_unleashed/abi-mismatch.rs +++ b/tests/ui/consts/miri_unleashed/abi-mismatch.rs @@ -1,8 +1,6 @@ // Checks that we report ABI mismatches for "const extern fn" //@ compile-flags: -Z unleash-the-miri-inside-of-you -#![feature(const_extern_fn)] - const extern "C" fn c_fn() {} const fn call_rust_fn(my_fn: extern "Rust" fn()) { diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr index 51364b01a2d..639795efae7 100644 --- a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr +++ b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr @@ -1,16 +1,16 @@ error[E0080]: could not evaluate static initializer - --> $DIR/abi-mismatch.rs:9:5 + --> $DIR/abi-mismatch.rs:7:5 | LL | my_fn(); | ^^^^^^^ calling a function with calling convention C using calling convention Rust | note: inside `call_rust_fn` - --> $DIR/abi-mismatch.rs:9:5 + --> $DIR/abi-mismatch.rs:7:5 | LL | my_fn(); | ^^^^^^^ note: inside `VAL` - --> $DIR/abi-mismatch.rs:15:18 + --> $DIR/abi-mismatch.rs:13:18 | LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern " warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/abi-mismatch.rs:9:5 + --> $DIR/abi-mismatch.rs:7:5 | LL | my_fn(); | ^^^^^^^ diff --git a/tests/ui/consts/unwind-abort.rs b/tests/ui/consts/unwind-abort.rs index 1dd33f327fb..b62fa81da06 100644 --- a/tests/ui/consts/unwind-abort.rs +++ b/tests/ui/consts/unwind-abort.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(const_extern_fn)] - // We don't unwind in const-eval anyways. const extern "C" fn foo() { panic!() diff --git a/tests/ui/parser/fn-header-semantic-fail.rs b/tests/ui/parser/fn-header-semantic-fail.rs index 5907ac05260..972e52d75da 100644 --- a/tests/ui/parser/fn-header-semantic-fail.rs +++ b/tests/ui/parser/fn-header-semantic-fail.rs @@ -2,8 +2,6 @@ //@ edition:2018 -#![feature(const_extern_fn)] - fn main() { async fn ff1() {} // OK. unsafe fn ff2() {} // OK. diff --git a/tests/ui/parser/fn-header-semantic-fail.stderr b/tests/ui/parser/fn-header-semantic-fail.stderr index b519ddbe2b4..dda42f24b32 100644 --- a/tests/ui/parser/fn-header-semantic-fail.stderr +++ b/tests/ui/parser/fn-header-semantic-fail.stderr @@ -1,5 +1,5 @@ error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:12:5 + --> $DIR/fn-header-semantic-fail.rs:10:5 | LL | const async unsafe extern "C" fn ff5() {} | ^^^^^-^^^^^------------------------------ @@ -8,7 +8,7 @@ LL | const async unsafe extern "C" fn ff5() {} | `const` because of this error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:18:9 + --> $DIR/fn-header-semantic-fail.rs:16:9 | LL | const fn ft3(); | ^^^^^- @@ -17,7 +17,7 @@ LL | const fn ft3(); | help: remove the `const` error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:20:9 + --> $DIR/fn-header-semantic-fail.rs:18:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^- @@ -26,7 +26,7 @@ LL | const async unsafe extern "C" fn ft5(); | help: remove the `const` error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:20:9 + --> $DIR/fn-header-semantic-fail.rs:18:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^-^^^^^---------------------------- @@ -35,7 +35,7 @@ LL | const async unsafe extern "C" fn ft5(); | `const` because of this error[E0379]: functions in trait impls cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:29:9 + --> $DIR/fn-header-semantic-fail.rs:27:9 | LL | const fn ft3() {} | ^^^^^- @@ -44,7 +44,7 @@ LL | const fn ft3() {} | help: remove the `const` error[E0379]: functions in trait impls cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:31:9 + --> $DIR/fn-header-semantic-fail.rs:29:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^- @@ -53,7 +53,7 @@ LL | const async unsafe extern "C" fn ft5() {} | help: remove the `const` error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:31:9 + --> $DIR/fn-header-semantic-fail.rs:29:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^-^^^^^------------------------------ @@ -62,7 +62,7 @@ LL | const async unsafe extern "C" fn ft5() {} | `const` because of this error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:41:9 + --> $DIR/fn-header-semantic-fail.rs:39:9 | LL | const async unsafe extern "C" fn fi5() {} | ^^^^^-^^^^^------------------------------ @@ -71,7 +71,7 @@ LL | const async unsafe extern "C" fn fi5() {} | `const` because of this error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:46:9 + --> $DIR/fn-header-semantic-fail.rs:44:9 | LL | extern "C" { | ---------- in this `extern` block @@ -79,7 +79,7 @@ LL | async fn fe1(); | ^^^^^ help: remove this qualifier error: items in unadorned `extern` blocks cannot have safety qualifiers - --> $DIR/fn-header-semantic-fail.rs:47:9 + --> $DIR/fn-header-semantic-fail.rs:45:9 | LL | unsafe fn fe2(); | ^^^^^^^^^^^^^^^^ @@ -90,7 +90,7 @@ LL | unsafe extern "C" { | ++++++ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:48:9 + --> $DIR/fn-header-semantic-fail.rs:46:9 | LL | extern "C" { | ---------- in this `extern` block @@ -99,7 +99,7 @@ LL | const fn fe3(); | ^^^^^ help: remove this qualifier error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:49:9 + --> $DIR/fn-header-semantic-fail.rs:47:9 | LL | extern "C" { | ---------- in this `extern` block @@ -108,7 +108,7 @@ LL | extern "C" fn fe4(); | ^^^^^^^^^^ help: remove this qualifier error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:50:15 + --> $DIR/fn-header-semantic-fail.rs:48:15 | LL | extern "C" { | ---------- in this `extern` block @@ -117,7 +117,7 @@ LL | const async unsafe extern "C" fn fe5(); | ^^^^^ help: remove this qualifier error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:50:9 + --> $DIR/fn-header-semantic-fail.rs:48:9 | LL | extern "C" { | ---------- in this `extern` block @@ -126,7 +126,7 @@ LL | const async unsafe extern "C" fn fe5(); | ^^^^^ help: remove this qualifier error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:50:28 + --> $DIR/fn-header-semantic-fail.rs:48:28 | LL | extern "C" { | ---------- in this `extern` block @@ -135,7 +135,7 @@ LL | const async unsafe extern "C" fn fe5(); | ^^^^^^^^^^ help: remove this qualifier error: items in unadorned `extern` blocks cannot have safety qualifiers - --> $DIR/fn-header-semantic-fail.rs:50:9 + --> $DIR/fn-header-semantic-fail.rs:48:9 | LL | const async unsafe extern "C" fn fe5(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -146,7 +146,7 @@ LL | unsafe extern "C" { | ++++++ error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:50:9 + --> $DIR/fn-header-semantic-fail.rs:48:9 | LL | const async unsafe extern "C" fn fe5(); | ^^^^^-^^^^^----------------------------