about summary refs log tree commit diff
path: root/tests/ui/async-await/async-unsafe-fn-call-in-safe.rs
diff options
context:
space:
mode:
authorMatthew Jasper <mjjasper1@gmail.com>2023-10-05 14:57:14 +0000
committerMatthew Jasper <mjjasper1@gmail.com>2023-10-16 15:57:59 +0000
commit5cc83fd4a5fb4860f67cf0b92b41c1aa9f87a54b (patch)
tree19a25efe92001a7c5adf562cf6de693f5d6de02f /tests/ui/async-await/async-unsafe-fn-call-in-safe.rs
parente7bdc5f9f869219e8d20060b42a09ea10a837851 (diff)
downloadrust-5cc83fd4a5fb4860f67cf0b92b41c1aa9f87a54b.tar.gz
rust-5cc83fd4a5fb4860f67cf0b92b41c1aa9f87a54b.zip
Fix inline const pattern unsafety checking in THIR
THIR unsafety checking was getting a cycle of
function unsafety checking
-> building THIR for the function
-> evaluating pattern inline constants in the function
-> building MIR for the inline constant
-> checking unsafety of functions (so that THIR can be stolen)
This is fixed by not stealing THIR when generating MIR but instead when
unsafety checking.
This leaves an issue with pattern inline constants not being unsafety
checked because they are evaluated away when generating THIR.
To fix that we now represent inline constants in THIR patterns and
visit them in THIR unsafety checking.
Diffstat (limited to 'tests/ui/async-await/async-unsafe-fn-call-in-safe.rs')
-rw-r--r--tests/ui/async-await/async-unsafe-fn-call-in-safe.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/ui/async-await/async-unsafe-fn-call-in-safe.rs b/tests/ui/async-await/async-unsafe-fn-call-in-safe.rs
index c941dc27aa3..14cc0dc614f 100644
--- a/tests/ui/async-await/async-unsafe-fn-call-in-safe.rs
+++ b/tests/ui/async-await/async-unsafe-fn-call-in-safe.rs
@@ -20,6 +20,10 @@ async fn g() {
 }
 
 fn main() {
-    S::f(); //[mir]~ ERROR call to unsafe function is unsafe
-    f(); //[mir]~ ERROR call to unsafe function is unsafe
+    S::f();
+    //[mir]~^ ERROR call to unsafe function is unsafe
+    //[thir]~^^ ERROR call to unsafe function `S::f` is unsafe
+    f();
+    //[mir]~^ ERROR call to unsafe function is unsafe
+    //[thir]~^^ ERROR call to unsafe function `f` is unsafe
 }