about summary refs log tree commit diff
path: root/src/test/ui/proc-macro
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-13 13:56:15 +0000
committerbors <bors@rust-lang.org>2021-01-13 13:56:15 +0000
commitfd2df74902fa98bcb71f85fd548c3eb399e6a96a (patch)
treed88a7bde6091f82bd2ae5d492c66088ef705600d /src/test/ui/proc-macro
parent116d1a7056830ccf649f74f823de4333ed329392 (diff)
parent4614671cae99ff35e61708ab64e9ba7850711750 (diff)
downloadrust-fd2df74902fa98bcb71f85fd548c3eb399e6a96a.tar.gz
rust-fd2df74902fa98bcb71f85fd548c3eb399e6a96a.zip
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/proc-macro')
-rw-r--r--src/test/ui/proc-macro/macros-in-extern-derive.rs2
-rw-r--r--src/test/ui/proc-macro/macros-in-extern.rs6
-rw-r--r--src/test/ui/proc-macro/signature.rs2
-rw-r--r--src/test/ui/proc-macro/signature.stderr2
-rw-r--r--src/test/ui/proc-macro/span-preservation.rs2
-rw-r--r--src/test/ui/proc-macro/span-preservation.stderr4
6 files changed, 10 insertions, 8 deletions
diff --git a/src/test/ui/proc-macro/macros-in-extern-derive.rs b/src/test/ui/proc-macro/macros-in-extern-derive.rs
index d2751a353bd..e52bf435a12 100644
--- a/src/test/ui/proc-macro/macros-in-extern-derive.rs
+++ b/src/test/ui/proc-macro/macros-in-extern-derive.rs
@@ -1,4 +1,4 @@
-extern {
+extern "C" {
     #[derive(Copy)] //~ ERROR `derive` may only be applied to structs, enums and unions
     fn f();
 }
diff --git a/src/test/ui/proc-macro/macros-in-extern.rs b/src/test/ui/proc-macro/macros-in-extern.rs
index e2b1d55aedc..57e2066d83c 100644
--- a/src/test/ui/proc-macro/macros-in-extern.rs
+++ b/src/test/ui/proc-macro/macros-in-extern.rs
@@ -11,12 +11,14 @@ fn main() {
 }
 
 #[link(name = "rust_test_helpers", kind = "static")]
-extern {
+extern "C" {
     #[empty_attr]
     fn some_definitely_unknown_symbol_which_should_be_removed();
 
     #[identity_attr]
     fn rust_get_test_int() -> isize;
 
-    identity!(fn rust_dbg_extern_identity_u32(arg: u32) -> u32;);
+    identity!(
+        fn rust_dbg_extern_identity_u32(arg: u32) -> u32;
+    );
 }
diff --git a/src/test/ui/proc-macro/signature.rs b/src/test/ui/proc-macro/signature.rs
index dbc1577172f..e08928716b0 100644
--- a/src/test/ui/proc-macro/signature.rs
+++ b/src/test/ui/proc-macro/signature.rs
@@ -7,7 +7,7 @@
 extern crate proc_macro;
 
 #[proc_macro_derive(A)]
-pub unsafe extern fn foo(a: i32, b: u32) -> u32 {
+pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 {
     //~^ ERROR: mismatched types
     loop {}
 }
diff --git a/src/test/ui/proc-macro/signature.stderr b/src/test/ui/proc-macro/signature.stderr
index 6ebc99601c4..80a459c4125 100644
--- a/src/test/ui/proc-macro/signature.stderr
+++ b/src/test/ui/proc-macro/signature.stderr
@@ -1,7 +1,7 @@
 error[E0308]: mismatched types
   --> $DIR/signature.rs:10:1
    |
-LL | / pub unsafe extern fn foo(a: i32, b: u32) -> u32 {
+LL | / pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 {
 LL | |
 LL | |     loop {}
 LL | | }
diff --git a/src/test/ui/proc-macro/span-preservation.rs b/src/test/ui/proc-macro/span-preservation.rs
index b22e50c4c17..0c735865558 100644
--- a/src/test/ui/proc-macro/span-preservation.rs
+++ b/src/test/ui/proc-macro/span-preservation.rs
@@ -35,7 +35,7 @@ fn c() {
 }
 
 #[recollect_attr]
-extern fn bar() {
+extern "C" fn bar() {
     0 //~ ERROR mismatched types
 }
 
diff --git a/src/test/ui/proc-macro/span-preservation.stderr b/src/test/ui/proc-macro/span-preservation.stderr
index 4064c5b3819..9e91ed4068b 100644
--- a/src/test/ui/proc-macro/span-preservation.stderr
+++ b/src/test/ui/proc-macro/span-preservation.stderr
@@ -37,8 +37,8 @@ LL |     let y = Foo { a: 10, b: 10isize };
 error[E0308]: mismatched types
   --> $DIR/span-preservation.rs:39:5
    |
-LL | extern fn bar() {
-   |                 - possibly return type missing here?
+LL | extern "C" fn bar() {
+   |                     - possibly return type missing here?
 LL |     0
    |     ^ expected `()`, found integer