Change DefKind::Static
to a struct variant
This commit is contained in:
parent
12e2846514
commit
9816915954
47 changed files with 90 additions and 86 deletions
|
@ -343,7 +343,7 @@ impl<'hir> Map<'hir> {
|
|||
DefKind::InlineConst => BodyOwnerKind::Const { inline: true },
|
||||
DefKind::Ctor(..) | DefKind::Fn | DefKind::AssocFn => BodyOwnerKind::Fn,
|
||||
DefKind::Closure => BodyOwnerKind::Closure,
|
||||
DefKind::Static(mt) => BodyOwnerKind::Static(mt),
|
||||
DefKind::Static { mt } => BodyOwnerKind::Static(mt),
|
||||
dk => bug!("{:?} is not a body node: {:?}", def_id, dk),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -498,8 +498,8 @@ 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(hir::Mutability::Not), _) => write!(w, "static ")?,
|
||||
(DefKind::Static(hir::Mutability::Mut), _) => write!(w, "static mut ")?,
|
||||
(DefKind::Static { mt: hir::Mutability::Not }, _) => write!(w, "static ")?,
|
||||
(DefKind::Static { mt: hir::Mutability::Mut }, _) => write!(w, "static mut ")?,
|
||||
(_, _) if is_function => write!(w, "fn ")?,
|
||||
(DefKind::AnonConst | DefKind::InlineConst, _) => {} // things like anon const, not an item
|
||||
_ => bug!("Unexpected def kind {:?}", kind),
|
||||
|
|
|
@ -1708,7 +1708,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
debug!("returned from def_kind: {:?}", def_kind);
|
||||
match def_kind {
|
||||
DefKind::Const
|
||||
| DefKind::Static(..)
|
||||
| DefKind::Static { .. }
|
||||
| DefKind::AssocConst
|
||||
| DefKind::Ctor(..)
|
||||
| DefKind::AnonConst
|
||||
|
|
|
@ -359,7 +359,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
|||
| DefKind::TyAlias
|
||||
| DefKind::Fn
|
||||
| DefKind::Const
|
||||
| DefKind::Static(_) = kind
|
||||
| DefKind::Static { .. } = kind
|
||||
{
|
||||
} else {
|
||||
// If not covered above, like for example items out of `impl` blocks, fallback.
|
||||
|
|
|
@ -616,12 +616,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
/// Returns `true` if the node pointed to by `def_id` is a `static` item.
|
||||
#[inline]
|
||||
pub fn is_static(self, def_id: DefId) -> bool {
|
||||
matches!(self.def_kind(def_id), DefKind::Static(_))
|
||||
matches!(self.def_kind(def_id), DefKind::Static { .. })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn static_mutability(self, def_id: DefId) -> Option<hir::Mutability> {
|
||||
if let DefKind::Static(mt) = self.def_kind(def_id) { Some(mt) } else { None }
|
||||
if let DefKind::Static { mt } = self.def_kind(def_id) { Some(mt) } else { None }
|
||||
}
|
||||
|
||||
/// Returns `true` if this is a `static` item with the `#[thread_local]` attribute.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue