Skip to content

Commit 081ea19

Browse files
committed
Auto merge of #135031 - RalfJung:intrinsics-without-body, r=oli-obk
rustc_intrinsic: support functions without body We synthesize a HIR body `loop {}` but such bodyless intrinsics. Most of the diff is due to turning `ItemKind::Fn` into a brace (named-field) enum variant, because it carries a `bool`-typed field now. This is to remember whether the function has a body. MIR building panics to avoid ever translating the fake `loop {}` body, and the intrinsic logic uses the lack of a body to implicitly mark that intrinsic as must-be-overridden. I first tried actually having no body rather than generating the fake body, but there's a *lot* of code that assumes that all function items have HIR and MIR, so this didn't work very well. Then I noticed that even `rustc_intrinsic_must_be_overridden` intrinsics have MIR generated (they are filled with an `Unreachable` terminator) so I guess I am not the first to discover this. ;) r? `@oli-obk`
2 parents 9fdf5b1 + 13b91dd commit 081ea19

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/bin/miri.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
242242
let is_reachable_non_generic = matches!(
243243
tcx.hir_node_by_def_id(local_def_id),
244244
Node::Item(&hir::Item {
245-
kind: hir::ItemKind::Static(..) | hir::ItemKind::Fn(..),
245+
kind: hir::ItemKind::Static(..) | hir::ItemKind::Fn{ .. },
246246
..
247247
}) | Node::ImplItem(&hir::ImplItem {
248248
kind: hir::ImplItemKind::Fn(..),

0 commit comments

Comments
 (0)