Make asm a named field
This commit is contained in:
parent
794c12416b
commit
2a6daaf89a
23 changed files with 30 additions and 28 deletions
|
@ -251,7 +251,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
.arena
|
||||
.alloc_from_iter(fm.items.iter().map(|x| self.lower_foreign_item_ref(x))),
|
||||
},
|
||||
ItemKind::GlobalAsm(asm) => hir::ItemKind::GlobalAsm(self.lower_inline_asm(span, asm)),
|
||||
ItemKind::GlobalAsm(asm) => {
|
||||
hir::ItemKind::GlobalAsm { asm: self.lower_inline_asm(span, asm) }
|
||||
}
|
||||
ItemKind::TyAlias(box TyAlias { generics, where_clauses, ty, .. }) => {
|
||||
// We lower
|
||||
//
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::prelude::*;
|
|||
|
||||
pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String, item_id: ItemId) {
|
||||
let item = tcx.hir_item(item_id);
|
||||
if let rustc_hir::ItemKind::GlobalAsm(asm) = item.kind {
|
||||
if let rustc_hir::ItemKind::GlobalAsm { asm } = item.kind {
|
||||
let is_x86 =
|
||||
matches!(tcx.sess.asm_arch.unwrap(), InlineAsmArch::X86 | InlineAsmArch::X86_64);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
|
|||
}
|
||||
MonoItem::GlobalAsm(item_id) => {
|
||||
let item = cx.tcx().hir_item(item_id);
|
||||
if let hir::ItemKind::GlobalAsm(asm) = item.kind {
|
||||
if let hir::ItemKind::GlobalAsm { asm } = item.kind {
|
||||
let operands: Vec<_> = asm
|
||||
.operands
|
||||
.iter()
|
||||
|
|
|
@ -3848,7 +3848,7 @@ impl<'hir> Item<'hir> {
|
|||
expect_foreign_mod, (ExternAbi, &'hir [ForeignItemRef]),
|
||||
ItemKind::ForeignMod { abi, items }, (*abi, items);
|
||||
|
||||
expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm(asm), asm;
|
||||
expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm { asm }, asm;
|
||||
|
||||
expect_ty_alias, (&'hir Ty<'hir>, &'hir Generics<'hir>),
|
||||
ItemKind::TyAlias(ty, generics), (ty, generics);
|
||||
|
@ -4015,7 +4015,7 @@ pub enum ItemKind<'hir> {
|
|||
/// An external module, e.g. `extern { .. }`.
|
||||
ForeignMod { abi: ExternAbi, items: &'hir [ForeignItemRef] },
|
||||
/// Module-level inline assembly (from `global_asm!`).
|
||||
GlobalAsm(&'hir InlineAsm<'hir>),
|
||||
GlobalAsm { asm: &'hir InlineAsm<'hir> },
|
||||
/// A type alias, e.g., `type Foo = Bar<u8>`.
|
||||
TyAlias(&'hir Ty<'hir>, &'hir Generics<'hir>),
|
||||
/// An enum definition, e.g., `enum Foo<A, B> {C<A>, D<B>}`.
|
||||
|
@ -4081,7 +4081,7 @@ impl ItemKind<'_> {
|
|||
ItemKind::Macro(..) => "macro",
|
||||
ItemKind::Mod(..) => "module",
|
||||
ItemKind::ForeignMod { .. } => "extern block",
|
||||
ItemKind::GlobalAsm(..) => "global asm item",
|
||||
ItemKind::GlobalAsm { .. } => "global asm item",
|
||||
ItemKind::TyAlias(..) => "type alias",
|
||||
ItemKind::Enum(..) => "enum",
|
||||
ItemKind::Struct(..) => "struct",
|
||||
|
|
|
@ -573,7 +573,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
|
|||
try_visit!(visitor.visit_id(item.hir_id()));
|
||||
walk_list!(visitor, visit_foreign_item_ref, items);
|
||||
}
|
||||
ItemKind::GlobalAsm(asm) => {
|
||||
ItemKind::GlobalAsm { asm } => {
|
||||
try_visit!(visitor.visit_id(item.hir_id()));
|
||||
try_visit!(visitor.visit_inline_asm(asm, item.hir_id()));
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ impl Target {
|
|||
ItemKind::Macro(..) => Target::MacroDef,
|
||||
ItemKind::Mod(..) => Target::Mod,
|
||||
ItemKind::ForeignMod { .. } => Target::ForeignMod,
|
||||
ItemKind::GlobalAsm(..) => Target::GlobalAsm,
|
||||
ItemKind::GlobalAsm { .. } => Target::GlobalAsm,
|
||||
ItemKind::TyAlias(..) => Target::TyAlias,
|
||||
ItemKind::Enum(..) => Target::Enum,
|
||||
ItemKind::Struct(..) => Target::Struct,
|
||||
|
|
|
@ -897,7 +897,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
|
|||
}
|
||||
DefKind::GlobalAsm => {
|
||||
let it = tcx.hir().expect_item(def_id);
|
||||
let hir::ItemKind::GlobalAsm(asm) = it.kind else {
|
||||
let hir::ItemKind::GlobalAsm { asm } = it.kind else {
|
||||
span_bug!(it.span, "DefKind::GlobalAsm but got {:#?}", it)
|
||||
};
|
||||
InlineAsmCtxt::new_global_asm(tcx).check_asm(asm, def_id);
|
||||
|
|
|
@ -680,7 +680,7 @@ fn lower_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
|
|||
| hir::ItemKind::Use(..)
|
||||
| hir::ItemKind::Macro(..)
|
||||
| hir::ItemKind::Mod(_)
|
||||
| hir::ItemKind::GlobalAsm(_) => {}
|
||||
| hir::ItemKind::GlobalAsm { .. } => {}
|
||||
hir::ItemKind::ForeignMod { items, .. } => {
|
||||
for item in *items {
|
||||
let item = tcx.hir_foreign_item(item.id);
|
||||
|
|
|
@ -630,7 +630,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
| hir::ItemKind::Mod(..)
|
||||
| hir::ItemKind::ForeignMod { .. }
|
||||
| hir::ItemKind::Static(..)
|
||||
| hir::ItemKind::GlobalAsm(..) => {
|
||||
| hir::ItemKind::GlobalAsm { .. } => {
|
||||
// These sorts of items have no lifetime parameters at all.
|
||||
intravisit::walk_item(self, item);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ fn anon_const_type_of<'tcx>(icx: &ItemCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx
|
|||
|
||||
// Anon consts outside the type system.
|
||||
Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
|
||||
| Node::Item(&Item { kind: ItemKind::GlobalAsm(asm), .. })
|
||||
| Node::Item(&Item { kind: ItemKind::GlobalAsm { asm }, .. })
|
||||
if let Some((anon_const, op_sp)) = asm.operands.iter().find_map(find_sym_fn) =>
|
||||
{
|
||||
let ty = tcx.typeck(def_id).node_type(hir_id);
|
||||
|
@ -83,7 +83,7 @@ fn anon_const_type_of<'tcx>(icx: &ItemCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx
|
|||
}
|
||||
}
|
||||
Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
|
||||
| Node::Item(&Item { kind: ItemKind::GlobalAsm(asm), .. })
|
||||
| Node::Item(&Item { kind: ItemKind::GlobalAsm { asm }, .. })
|
||||
if let Some((anon_const, op_sp)) = asm.operands.iter().find_map(find_const) =>
|
||||
{
|
||||
let ty = tcx.typeck(def_id).node_type(hir_id);
|
||||
|
@ -318,7 +318,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
|
|||
| ItemKind::Macro(..)
|
||||
| ItemKind::Mod(..)
|
||||
| ItemKind::ForeignMod { .. }
|
||||
| ItemKind::GlobalAsm(..)
|
||||
| ItemKind::GlobalAsm { .. }
|
||||
| ItemKind::ExternCrate(..)
|
||||
| ItemKind::Use(..) => {
|
||||
span_bug!(item.span, "compute_type_of_item: unexpected item type: {:?}", item.kind);
|
||||
|
|
|
@ -692,7 +692,7 @@ impl<'a> State<'a> {
|
|||
}
|
||||
self.bclose(item.span);
|
||||
}
|
||||
hir::ItemKind::GlobalAsm(asm) => {
|
||||
hir::ItemKind::GlobalAsm { asm } => {
|
||||
self.head("global_asm!");
|
||||
self.print_inline_asm(asm);
|
||||
self.end()
|
||||
|
|
|
@ -277,7 +277,7 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
|
|||
Some(fcx.next_ty_var(span))
|
||||
}
|
||||
Node::Expr(&hir::Expr { kind: hir::ExprKind::InlineAsm(asm), span, .. })
|
||||
| Node::Item(&hir::Item { kind: hir::ItemKind::GlobalAsm(asm), span, .. }) => {
|
||||
| Node::Item(&hir::Item { kind: hir::ItemKind::GlobalAsm { asm }, span, .. }) => {
|
||||
asm.operands.iter().find_map(|(op, _op_sp)| match op {
|
||||
hir::InlineAsmOperand::Const { anon_const }
|
||||
| hir::InlineAsmOperand::SymFn { anon_const }
|
||||
|
|
|
@ -261,7 +261,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
|
|||
HirItem::ForeignMod { .. } => ("ItemForeignMod", LABELS_HIR_ONLY),
|
||||
|
||||
// Module-level inline assembly (from global_asm!)
|
||||
HirItem::GlobalAsm(..) => ("ItemGlobalAsm", LABELS_HIR_ONLY),
|
||||
HirItem::GlobalAsm { .. } => ("ItemGlobalAsm", LABELS_HIR_ONLY),
|
||||
|
||||
// A type alias, e.g., `type Foo = Bar<u8>`
|
||||
HirItem::TyAlias(..) => ("ItemTy", LABELS_HIR_ONLY),
|
||||
|
|
|
@ -1740,7 +1740,7 @@ impl<'tcx> LateLintPass<'tcx> for ImproperCTypesDefinitions {
|
|||
hir::ItemKind::Impl(..)
|
||||
| hir::ItemKind::TraitAlias(..)
|
||||
| hir::ItemKind::Trait(..)
|
||||
| hir::ItemKind::GlobalAsm(..)
|
||||
| hir::ItemKind::GlobalAsm { .. }
|
||||
| hir::ItemKind::ForeignMod { .. }
|
||||
| hir::ItemKind::Mod(..)
|
||||
| hir::ItemKind::Macro(..)
|
||||
|
|
|
@ -1166,7 +1166,7 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
|
|||
ItemKind::Macro(..) => "macro",
|
||||
ItemKind::Mod(..) => "mod",
|
||||
ItemKind::ForeignMod { .. } => "foreign mod",
|
||||
ItemKind::GlobalAsm(..) => "global asm",
|
||||
ItemKind::GlobalAsm { .. } => "global asm",
|
||||
ItemKind::TyAlias(..) => "ty",
|
||||
ItemKind::Enum(..) => "enum",
|
||||
ItemKind::Struct(..) => "struct",
|
||||
|
|
|
@ -479,7 +479,7 @@ fn collect_items_rec<'tcx>(
|
|||
recursion_depth_reset = None;
|
||||
|
||||
let item = tcx.hir_item(item_id);
|
||||
if let hir::ItemKind::GlobalAsm(asm) = item.kind {
|
||||
if let hir::ItemKind::GlobalAsm { asm } = item.kind {
|
||||
for (op, op_sp) in asm.operands {
|
||||
match op {
|
||||
hir::InlineAsmOperand::Const { .. } => {
|
||||
|
|
|
@ -246,7 +246,7 @@ impl<'tcx> ReachableContext<'tcx> {
|
|||
| hir::ItemKind::Struct(..)
|
||||
| hir::ItemKind::Enum(..)
|
||||
| hir::ItemKind::Union(..)
|
||||
| hir::ItemKind::GlobalAsm(..) => {}
|
||||
| hir::ItemKind::GlobalAsm { .. } => {}
|
||||
}
|
||||
}
|
||||
Node::TraitItem(trait_method) => {
|
||||
|
|
|
@ -645,7 +645,7 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
|
|||
// The interface is empty, and no nested items.
|
||||
hir::ItemKind::Use(..)
|
||||
| hir::ItemKind::ExternCrate(..)
|
||||
| hir::ItemKind::GlobalAsm(..) => {}
|
||||
| hir::ItemKind::GlobalAsm { .. } => {}
|
||||
// The interface is empty, and all nested items are processed by `visit_item`.
|
||||
hir::ItemKind::Mod(..) => {}
|
||||
hir::ItemKind::Macro(macro_def, _) => {
|
||||
|
|
|
@ -288,7 +288,7 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
|
|||
| ItemKind::Use(_, _)
|
||||
| ItemKind::ExternCrate(_)
|
||||
| ItemKind::ForeignMod { .. }
|
||||
| ItemKind::GlobalAsm(_)
|
||||
| ItemKind::GlobalAsm { .. }
|
||||
// We already have "visit_mod" above so no need to check it here.
|
||||
| ItemKind::Mod(_) => {}
|
||||
}
|
||||
|
|
|
@ -439,7 +439,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
}
|
||||
// If we're inlining, skip private items.
|
||||
_ if self.inlining && !is_pub => {}
|
||||
hir::ItemKind::GlobalAsm(..) => {}
|
||||
hir::ItemKind::GlobalAsm { .. } => {}
|
||||
hir::ItemKind::Use(_, hir::UseKind::ListStem) => {}
|
||||
hir::ItemKind::Use(path, kind) => {
|
||||
for &res in &path.res {
|
||||
|
|
|
@ -362,7 +362,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
|
|||
}
|
||||
} else if let ItemKind::ForeignMod { .. } = item.kind {
|
||||
continue;
|
||||
} else if let ItemKind::GlobalAsm(_) = item.kind {
|
||||
} else if let ItemKind::GlobalAsm { .. } = item.kind {
|
||||
continue;
|
||||
} else if let ItemKind::Use(path, use_kind) = item.kind {
|
||||
if path.segments.is_empty() {
|
||||
|
@ -467,7 +467,7 @@ fn convert_module_item_kind(value: &ItemKind<'_>) -> SourceItemOrderingModuleIte
|
|||
ItemKind::Macro(..) => Macro,
|
||||
ItemKind::Mod(..) => Mod,
|
||||
ItemKind::ForeignMod { .. } => ForeignMod,
|
||||
ItemKind::GlobalAsm(..) => GlobalAsm,
|
||||
ItemKind::GlobalAsm { .. } => GlobalAsm,
|
||||
ItemKind::TyAlias(..) => TyAlias,
|
||||
ItemKind::Enum(..) => Enum,
|
||||
ItemKind::Struct(..) => Struct,
|
||||
|
|
|
@ -217,7 +217,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
|||
| hir::ItemKind::Union(..) => {},
|
||||
hir::ItemKind::ExternCrate(..)
|
||||
| hir::ItemKind::ForeignMod { .. }
|
||||
| hir::ItemKind::GlobalAsm(..)
|
||||
| hir::ItemKind::GlobalAsm { .. }
|
||||
| hir::ItemKind::Impl { .. }
|
||||
| hir::ItemKind::Use(..) => note_prev_span_then_ret!(self.prev_span, it.span),
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
|||
| hir::ItemKind::Static(..)
|
||||
| hir::ItemKind::Struct(..)
|
||||
| hir::ItemKind::TraitAlias(..)
|
||||
| hir::ItemKind::GlobalAsm(..)
|
||||
| hir::ItemKind::GlobalAsm { .. }
|
||||
| hir::ItemKind::TyAlias(..)
|
||||
| hir::ItemKind::Union(..)
|
||||
| hir::ItemKind::ExternCrate(..)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue