about summary refs log tree commit diff
path: root/tests/ui/extern
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/extern')
-rw-r--r--tests/ui/extern/function-definition-in-extern-block-75283.rs7
-rw-r--r--tests/ui/extern/function-definition-in-extern-block-75283.stderr18
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/extern/function-definition-in-extern-block-75283.rs b/tests/ui/extern/function-definition-in-extern-block-75283.rs
new file mode 100644
index 00000000000..e2b7358743b
--- /dev/null
+++ b/tests/ui/extern/function-definition-in-extern-block-75283.rs
@@ -0,0 +1,7 @@
+// https://github.com/rust-lang/rust/issues/75283
+extern "C" {
+    fn lol() { //~ ERROR incorrect function inside `extern` block
+        println!("");
+    }
+}
+fn main() {}
diff --git a/tests/ui/extern/function-definition-in-extern-block-75283.stderr b/tests/ui/extern/function-definition-in-extern-block-75283.stderr
new file mode 100644
index 00000000000..67be1c29599
--- /dev/null
+++ b/tests/ui/extern/function-definition-in-extern-block-75283.stderr
@@ -0,0 +1,18 @@
+error: incorrect function inside `extern` block
+  --> $DIR/function-definition-in-extern-block-75283.rs:3:8
+   |
+LL |   extern "C" {
+   |   ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body
+LL |       fn lol() {
+   |  ________^^^___-
+   | |        |
+   | |        cannot have a body
+LL | |         println!("");
+LL | |     }
+   | |_____- help: remove the invalid body: `;`
+   |
+   = help: you might have meant to write a function accessible through FFI, which can be done by writing `extern fn` outside of the `extern` block
+   = note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html
+
+error: aborting due to 1 previous error
+