about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDelan Azabani <delan@azabani.com>2019-07-12 13:32:39 +1000
committerDelan Azabani <delan@azabani.com>2019-07-12 13:59:17 +1000
commit0f66ce65dbdef43e8459a3bc771d3fe05ad2063d (patch)
tree08fef2da4b306a84813919b5e8fc0c6c7048d202 /src
parent1574c2dee2e26d78fb0f00bcd97beabd326f6723 (diff)
test E0133 when calling free/impl `async unsafe fn` in safe code
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/async-await/async-unsafe-fn-call-in-safe.rs16
-rw-r--r--src/test/ui/async-await/async-unsafe-fn-call-in-safe.stderr19
2 files changed, 35 insertions, 0 deletions
diff --git a/src/test/ui/async-await/async-unsafe-fn-call-in-safe.rs b/src/test/ui/async-await/async-unsafe-fn-call-in-safe.rs
new file mode 100644
index 00000000000..f1a7d625669
--- /dev/null
+++ b/src/test/ui/async-await/async-unsafe-fn-call-in-safe.rs
@@ -0,0 +1,16 @@
+// edition:2018
+
+#![feature(async_await, async_closure)]
+
+struct S;
+
+impl S {
+    async unsafe fn f() {}
+}
+
+async unsafe fn f() {}
+
+fn main() {
+    S::f(); //~ ERROR call to unsafe function is unsafe
+    f(); //~ ERROR call to unsafe function is unsafe
+}
diff --git a/src/test/ui/async-await/async-unsafe-fn-call-in-safe.stderr b/src/test/ui/async-await/async-unsafe-fn-call-in-safe.stderr
new file mode 100644
index 00000000000..21ba45d7f1e
--- /dev/null
+++ b/src/test/ui/async-await/async-unsafe-fn-call-in-safe.stderr
@@ -0,0 +1,19 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
+   |
+LL |     S::f();
+   |     ^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
+   |
+LL |     f();
+   |     ^^^ 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
+
+For more information about this error, try `rustc --explain E0133`.