1
Fork 0

Add safe/unsafe to static inside extern blocks

This commit is contained in:
Santiago Pastorino 2024-05-07 14:43:23 +02:00
parent b4cbdb7246
commit bac72cf7cf
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
27 changed files with 152 additions and 57 deletions

View file

@ -305,7 +305,9 @@ impl<'hir> Map<'hir> {
DefKind::InlineConst => BodyOwnerKind::Const { inline: true },
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => BodyOwnerKind::Fn,
DefKind::Closure => BodyOwnerKind::Closure,
DefKind::Static { mutability, nested: false } => BodyOwnerKind::Static(mutability),
DefKind::Static { safety: _, mutability, nested: false } => {
BodyOwnerKind::Static(mutability)
}
dk => bug!("{:?} is not a body node: {:?}", def_id, dk),
}
}

View file

@ -559,10 +559,10 @@ fn write_mir_sig(tcx: TyCtxt<'_>, body: &Body<'_>, w: &mut dyn io::Write) -> io:
match (kind, body.source.promoted) {
(_, Some(_)) => write!(w, "const ")?, // promoteds are the closest to consts
(DefKind::Const | DefKind::AssocConst, _) => write!(w, "const ")?,
(DefKind::Static { mutability: hir::Mutability::Not, nested: false }, _) => {
(DefKind::Static { safety: _, mutability: hir::Mutability::Not, nested: false }, _) => {
write!(w, "static ")?
}
(DefKind::Static { mutability: hir::Mutability::Mut, nested: false }, _) => {
(DefKind::Static { safety: _, mutability: hir::Mutability::Mut, nested: false }, _) => {
write!(w, "static mut ")?
}
(_, _) if is_function => write!(w, "fn ")?,