From 19eaee2c329a428ba052ef30a5d51464b098e591 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Thu, 16 Sep 2021 22:49:34 +0100 Subject: [PATCH] Report heap allocation instead of non-const fn for exchange_malloc call --- .../rustc_const_eval/src/transform/check_consts/check.rs | 5 +++++ 1 file changed, 5 insertions(+) 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 8b28c8fa219d..57d92005a564 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 {