rustc_intrinsic: support functions without body; they are implicitly marked as must-be-overridden

This commit is contained in:
Ralf Jung
2025-01-04 11:41:51 +01:00
parent be65012aa3
commit 3cd3649c6c
19 changed files with 118 additions and 68 deletions

View File

@@ -3640,7 +3640,7 @@ impl<'hir> Item<'hir> {
ItemKind::Const(ty, generics, body), (ty, generics, *body);
expect_fn, (&FnSig<'hir>, &'hir Generics<'hir>, BodyId),
ItemKind::Fn { sig, generics, body }, (sig, generics, *body);
ItemKind::Fn { sig, generics, body, .. }, (sig, generics, *body);
expect_macro, (&ast::MacroDef, MacroKind), ItemKind::Macro(def, mk), (def, *mk);
@@ -3768,7 +3768,15 @@ pub enum ItemKind<'hir> {
/// A `const` item.
Const(&'hir Ty<'hir>, &'hir Generics<'hir>, BodyId),
/// A function declaration.
Fn { sig: FnSig<'hir>, generics: &'hir Generics<'hir>, body: BodyId },
Fn {
sig: FnSig<'hir>,
generics: &'hir Generics<'hir>,
body: BodyId,
/// Whether this function actually has a body.
/// For functions without a body, `body` is synthesized (to avoid ICEs all over the
/// compiler), but that code should never be translated.
has_body: bool,
},
/// A MBE macro definition (`macro_rules!` or `macro`).
Macro(&'hir ast::MacroDef, MacroKind),
/// A module.