rust/compiler/rustc_ast_lowering/src
bors fd127a3a84 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`
2025-01-04 12:50:38 +00:00
..
asm.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
block.rs (Re-)Implement impl_trait_in_bindings 2024-12-14 03:21:24 +00:00
delegation.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
errors.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
expr.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
format.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
index.rs Remove hir::ArrayLen, introduce ConstArgKind::Infer 2024-11-30 21:00:31 +01:00
item.rs rustc_intrinsic: support functions without body; they are implicitly marked as must-be-overridden 2025-01-04 11:41:51 +01:00
lib.rs Unconditionally lower generic_arg_infer 2025-01-02 23:39:16 +00:00
pat.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
path.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00