diff options
| author | Gary Guo <gary@garyguo.net> | 2021-09-16 22:49:34 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2021-09-25 01:08:41 +0100 |
| commit | 19eaee2c329a428ba052ef30a5d51464b098e591 (patch) | |
| tree | 4d8e424c29ba928f7170b317653fa6b962ece6b0 | |
| parent | 511333fcc41c2a70ece7fa8bd5e0a70adfcb84fd (diff) | |
| download | rust-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.rs | 5 |
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 { |
