about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2021-09-16 22:49:34 +0100
committerGary Guo <gary@garyguo.net>2021-09-25 01:08:41 +0100
commit19eaee2c329a428ba052ef30a5d51464b098e591 (patch)
tree4d8e424c29ba928f7170b317653fa6b962ece6b0
parent511333fcc41c2a70ece7fa8bd5e0a70adfcb84fd (diff)
downloadrust-19eaee2c329a428ba052ef30a5d51464b098e591.tar.gz
rust-19eaee2c329a428ba052ef30a5d51464b098e591.zip
Report heap allocation instead of non-const fn for exchange_malloc call
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/check.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs
index 8b28c8fa219..57d92005a56 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs
@@ -913,6 +913,11 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
                     return;
                 }
 
+                if Some(callee) == tcx.lang_items().exchange_malloc_fn() {
+                    self.check_op(ops::HeapAllocation);
+                    return;
+                }
+
                 // `async` blocks get lowered to `std::future::from_generator(/* a closure */)`.
                 let is_async_block = Some(callee) == tcx.lang_items().from_generator_fn();
                 if is_async_block {