diff options
| author | bors <bors@rust-lang.org> | 2021-01-13 13:56:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-13 13:56:15 +0000 |
| commit | fd2df74902fa98bcb71f85fd548c3eb399e6a96a (patch) | |
| tree | d88a7bde6091f82bd2ae5d492c66088ef705600d /src/test/ui/consts | |
| parent | 116d1a7056830ccf649f74f823de4333ed329392 (diff) | |
| parent | 4614671cae99ff35e61708ab64e9ba7850711750 (diff) | |
Auto merge of #76219 - Mark-Simulacrum:extern-require-abi, r=estebank
Add allow-by-default lint on implicit ABI in extern function pointers and items This adds a new lint, missing_abi, which lints on omitted ABIs on extern blocks, function declarations, and function pointers. It is currently not emitting the best possible diagnostics -- we need to track the span of "extern" at least or do some heuristic searching based on the available spans -- but seems good enough for an initial pass than can be expanded in future PRs. This is a pretty large PR, but mostly due to updating a large number of tests to include ABIs; I can split that into a separate PR if it would be helpful, but test updates are already in dedicated commits.
Diffstat (limited to 'src/test/ui/consts')
11 files changed, 23 insertions, 23 deletions
diff --git a/src/test/ui/consts/auxiliary/cci_const.rs b/src/test/ui/consts/auxiliary/cci_const.rs index af6a5ad8ed3..c83b3f4a5bb 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 39cc01a415e..2dc9539ba52 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 0d8609e334a..abeb24121eb 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-eval/extern_fat_pointer.rs b/src/test/ui/consts/const-eval/extern_fat_pointer.rs index f210d1a0a90..d91d07827dc 100644 --- a/src/test/ui/consts/const-eval/extern_fat_pointer.rs +++ b/src/test/ui/consts/const-eval/extern_fat_pointer.rs @@ -2,7 +2,7 @@ #![feature(extern_types)] -extern { +extern "C" { type Opaque; } 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 e18e0a83573..ee07dfae47c 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 645a957949c..76380ebcb65 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 694e2290808..80d234b0e88 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 <https://github.com/rust-lang/rust/issues/57241> for more information = help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable 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 cab175bbfa8..71e6c2cb858 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 1dc0f83cadf..2ce2eafd545 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 cfcf99b867a..01f487a7d75 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/consts/const-size_of_val-align_of_val-extern-type.rs b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs index 96a8a8452ed..09c7d5580de 100644 --- a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs +++ b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs @@ -2,9 +2,9 @@ #![feature(core_intrinsics)] #![feature(const_size_of_val, const_align_of_val)] -use std::intrinsics::{size_of_val, min_align_of_val}; +use std::intrinsics::{min_align_of_val, size_of_val}; -extern { +extern "C" { type Opaque; } |
