Skip to content

Commit 19eaee2

Browse files
committed
Report heap allocation instead of non-const fn for exchange_malloc call
1 parent 511333f commit 19eaee2

File tree

1 file changed

+5
-0
lines changed
  • compiler/rustc_const_eval/src/transform/check_consts

1 file changed

+5
-0
lines changed

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+5
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,11 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
913913
return;
914914
}
915915

916+
if Some(callee) == tcx.lang_items().exchange_malloc_fn() {
917+
self.check_op(ops::HeapAllocation);
918+
return;
919+
}
920+
916921
// `async` blocks get lowered to `std::future::from_generator(/* a closure */)`.
917922
let is_async_block = Some(callee) == tcx.lang_items().from_generator_fn();
918923
if is_async_block {

0 commit comments

Comments
 (0)