Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar
Move methods from Map to TyCtxt, part 4. A follow-up to https://github.com/rust-lang/rust/pull/137350. r? ```@Zalathar```
This commit is contained in:
commit
f88f27aff0
124 changed files with 390 additions and 441 deletions
|
@ -275,7 +275,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
span_bug!(
|
||||
self.hir().span(hir_id),
|
||||
"body_owned_by: {} has no associated body",
|
||||
self.hir().node_to_string(hir_id)
|
||||
self.hir_id_to_string(hir_id)
|
||||
);
|
||||
})
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
/// invoking `krate.attrs` because it registers a tighter
|
||||
/// dep-graph access.
|
||||
pub fn hir_krate_attrs(self) -> &'tcx [Attribute] {
|
||||
self.hir().attrs(CRATE_HIR_ID)
|
||||
self.hir_attrs(CRATE_HIR_ID)
|
||||
}
|
||||
|
||||
pub fn hir_rustc_coherence_is_core(self) -> bool {
|
||||
|
@ -674,104 +674,178 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'hir> Map<'hir> {
|
||||
pub fn get_foreign_abi(self, hir_id: HirId) -> ExternAbi {
|
||||
let parent = self.tcx.hir_get_parent_item(hir_id);
|
||||
/// Get a representation of this `id` for debugging purposes.
|
||||
/// NOTE: Do NOT use this in diagnostics!
|
||||
pub fn hir_id_to_string(self, id: HirId) -> String {
|
||||
let path_str = |def_id: LocalDefId| self.def_path_str(def_id);
|
||||
|
||||
let span_str = || {
|
||||
self.sess.source_map().span_to_snippet(Map { tcx: self }.span(id)).unwrap_or_default()
|
||||
};
|
||||
let node_str = |prefix| format!("{id} ({prefix} `{}`)", span_str());
|
||||
|
||||
match self.hir_node(id) {
|
||||
Node::Item(item) => {
|
||||
let item_str = match item.kind {
|
||||
ItemKind::ExternCrate(..) => "extern crate",
|
||||
ItemKind::Use(..) => "use",
|
||||
ItemKind::Static(..) => "static",
|
||||
ItemKind::Const(..) => "const",
|
||||
ItemKind::Fn { .. } => "fn",
|
||||
ItemKind::Macro(..) => "macro",
|
||||
ItemKind::Mod(..) => "mod",
|
||||
ItemKind::ForeignMod { .. } => "foreign mod",
|
||||
ItemKind::GlobalAsm { .. } => "global asm",
|
||||
ItemKind::TyAlias(..) => "ty",
|
||||
ItemKind::Enum(..) => "enum",
|
||||
ItemKind::Struct(..) => "struct",
|
||||
ItemKind::Union(..) => "union",
|
||||
ItemKind::Trait(..) => "trait",
|
||||
ItemKind::TraitAlias(..) => "trait alias",
|
||||
ItemKind::Impl { .. } => "impl",
|
||||
};
|
||||
format!("{id} ({item_str} {})", path_str(item.owner_id.def_id))
|
||||
}
|
||||
Node::ForeignItem(item) => {
|
||||
format!("{id} (foreign item {})", path_str(item.owner_id.def_id))
|
||||
}
|
||||
Node::ImplItem(ii) => {
|
||||
let kind = match ii.kind {
|
||||
ImplItemKind::Const(..) => "associated constant",
|
||||
ImplItemKind::Fn(fn_sig, _) => match fn_sig.decl.implicit_self {
|
||||
ImplicitSelfKind::None => "associated function",
|
||||
_ => "method",
|
||||
},
|
||||
ImplItemKind::Type(_) => "associated type",
|
||||
};
|
||||
format!("{id} ({kind} `{}` in {})", ii.ident, path_str(ii.owner_id.def_id))
|
||||
}
|
||||
Node::TraitItem(ti) => {
|
||||
let kind = match ti.kind {
|
||||
TraitItemKind::Const(..) => "associated constant",
|
||||
TraitItemKind::Fn(fn_sig, _) => match fn_sig.decl.implicit_self {
|
||||
ImplicitSelfKind::None => "associated function",
|
||||
_ => "trait method",
|
||||
},
|
||||
TraitItemKind::Type(..) => "associated type",
|
||||
};
|
||||
|
||||
format!("{id} ({kind} `{}` in {})", ti.ident, path_str(ti.owner_id.def_id))
|
||||
}
|
||||
Node::Variant(variant) => {
|
||||
format!("{id} (variant `{}` in {})", variant.ident, path_str(variant.def_id))
|
||||
}
|
||||
Node::Field(field) => {
|
||||
format!("{id} (field `{}` in {})", field.ident, path_str(field.def_id))
|
||||
}
|
||||
Node::AnonConst(_) => node_str("const"),
|
||||
Node::ConstBlock(_) => node_str("const"),
|
||||
Node::ConstArg(_) => node_str("const"),
|
||||
Node::Expr(_) => node_str("expr"),
|
||||
Node::ExprField(_) => node_str("expr field"),
|
||||
Node::Stmt(_) => node_str("stmt"),
|
||||
Node::PathSegment(_) => node_str("path segment"),
|
||||
Node::Ty(_) => node_str("type"),
|
||||
Node::AssocItemConstraint(_) => node_str("assoc item constraint"),
|
||||
Node::TraitRef(_) => node_str("trait ref"),
|
||||
Node::OpaqueTy(_) => node_str("opaque type"),
|
||||
Node::Pat(_) => node_str("pat"),
|
||||
Node::TyPat(_) => node_str("pat ty"),
|
||||
Node::PatField(_) => node_str("pattern field"),
|
||||
Node::PatExpr(_) => node_str("pattern literal"),
|
||||
Node::Param(_) => node_str("param"),
|
||||
Node::Arm(_) => node_str("arm"),
|
||||
Node::Block(_) => node_str("block"),
|
||||
Node::Infer(_) => node_str("infer"),
|
||||
Node::LetStmt(_) => node_str("local"),
|
||||
Node::Ctor(ctor) => format!(
|
||||
"{id} (ctor {})",
|
||||
ctor.ctor_def_id().map_or("<missing path>".into(), |def_id| path_str(def_id)),
|
||||
),
|
||||
Node::Lifetime(_) => node_str("lifetime"),
|
||||
Node::GenericParam(param) => {
|
||||
format!("{id} (generic_param {})", path_str(param.def_id))
|
||||
}
|
||||
Node::Crate(..) => String::from("(root_crate)"),
|
||||
Node::WherePredicate(_) => node_str("where predicate"),
|
||||
Node::Synthetic => unreachable!(),
|
||||
Node::Err(_) => node_str("error"),
|
||||
Node::PreciseCapturingNonLifetimeArg(_param) => node_str("parameter"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hir_get_foreign_abi(self, hir_id: HirId) -> ExternAbi {
|
||||
let parent = self.hir_get_parent_item(hir_id);
|
||||
if let OwnerNode::Item(Item { kind: ItemKind::ForeignMod { abi, .. }, .. }) =
|
||||
self.tcx.hir_owner_node(parent)
|
||||
self.hir_owner_node(parent)
|
||||
{
|
||||
return *abi;
|
||||
}
|
||||
bug!(
|
||||
"expected foreign mod or inlined parent, found {}",
|
||||
self.node_to_string(HirId::make_owner(parent.def_id))
|
||||
self.hir_id_to_string(HirId::make_owner(parent.def_id))
|
||||
)
|
||||
}
|
||||
|
||||
pub fn expect_item(self, id: LocalDefId) -> &'hir Item<'hir> {
|
||||
match self.tcx.expect_hir_owner_node(id) {
|
||||
pub fn hir_expect_item(self, id: LocalDefId) -> &'tcx Item<'tcx> {
|
||||
match self.expect_hir_owner_node(id) {
|
||||
OwnerNode::Item(item) => item,
|
||||
_ => bug!("expected item, found {}", self.node_to_string(HirId::make_owner(id))),
|
||||
_ => bug!("expected item, found {}", self.hir_id_to_string(HirId::make_owner(id))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_impl_item(self, id: LocalDefId) -> &'hir ImplItem<'hir> {
|
||||
match self.tcx.expect_hir_owner_node(id) {
|
||||
pub fn hir_expect_impl_item(self, id: LocalDefId) -> &'tcx ImplItem<'tcx> {
|
||||
match self.expect_hir_owner_node(id) {
|
||||
OwnerNode::ImplItem(item) => item,
|
||||
_ => bug!("expected impl item, found {}", self.node_to_string(HirId::make_owner(id))),
|
||||
_ => bug!("expected impl item, found {}", self.hir_id_to_string(HirId::make_owner(id))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_trait_item(self, id: LocalDefId) -> &'hir TraitItem<'hir> {
|
||||
match self.tcx.expect_hir_owner_node(id) {
|
||||
pub fn hir_expect_trait_item(self, id: LocalDefId) -> &'tcx TraitItem<'tcx> {
|
||||
match self.expect_hir_owner_node(id) {
|
||||
OwnerNode::TraitItem(item) => item,
|
||||
_ => bug!("expected trait item, found {}", self.node_to_string(HirId::make_owner(id))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_fn_output(self, def_id: LocalDefId) -> Option<&'hir FnRetTy<'hir>> {
|
||||
Some(&self.tcx.opt_hir_owner_node(def_id)?.fn_decl()?.output)
|
||||
}
|
||||
|
||||
pub fn expect_variant(self, id: HirId) -> &'hir Variant<'hir> {
|
||||
match self.tcx.hir_node(id) {
|
||||
Node::Variant(variant) => variant,
|
||||
_ => bug!("expected variant, found {}", self.node_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_field(self, id: HirId) -> &'hir FieldDef<'hir> {
|
||||
match self.tcx.hir_node(id) {
|
||||
Node::Field(field) => field,
|
||||
_ => bug!("expected field, found {}", self.node_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_foreign_item(self, id: OwnerId) -> &'hir ForeignItem<'hir> {
|
||||
match self.tcx.hir_owner_node(id) {
|
||||
OwnerNode::ForeignItem(item) => item,
|
||||
_ => {
|
||||
bug!(
|
||||
"expected foreign item, found {}",
|
||||
self.node_to_string(HirId::make_owner(id.def_id))
|
||||
)
|
||||
bug!("expected trait item, found {}", self.hir_id_to_string(HirId::make_owner(id)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hir_get_fn_output(self, def_id: LocalDefId) -> Option<&'tcx FnRetTy<'tcx>> {
|
||||
Some(&self.opt_hir_owner_node(def_id)?.fn_decl()?.output)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn expect_opaque_ty(self, id: LocalDefId) -> &'hir OpaqueTy<'hir> {
|
||||
match self.tcx.hir_node_by_def_id(id) {
|
||||
pub fn hir_expect_opaque_ty(self, id: LocalDefId) -> &'tcx OpaqueTy<'tcx> {
|
||||
match self.hir_node_by_def_id(id) {
|
||||
Node::OpaqueTy(opaq) => opaq,
|
||||
_ => {
|
||||
bug!(
|
||||
"expected opaque type definition, found {}",
|
||||
self.node_to_string(self.tcx.local_def_id_to_hir_id(id))
|
||||
self.hir_id_to_string(self.local_def_id_to_hir_id(id))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_expr(self, id: HirId) -> &'hir Expr<'hir> {
|
||||
match self.tcx.hir_node(id) {
|
||||
pub fn hir_expect_expr(self, id: HirId) -> &'tcx Expr<'tcx> {
|
||||
match self.hir_node(id) {
|
||||
Node::Expr(expr) => expr,
|
||||
_ => bug!("expected expr, found {}", self.node_to_string(id)),
|
||||
_ => bug!("expected expr, found {}", self.hir_id_to_string(id)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn opt_delegation_sig_id(self, def_id: LocalDefId) -> Option<DefId> {
|
||||
self.tcx.opt_hir_owner_node(def_id)?.fn_decl()?.opt_delegation_sig_id()
|
||||
pub fn hir_opt_delegation_sig_id(self, def_id: LocalDefId) -> Option<DefId> {
|
||||
self.opt_hir_owner_node(def_id)?.fn_decl()?.opt_delegation_sig_id()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn opt_ident(self, id: HirId) -> Option<Ident> {
|
||||
match self.tcx.hir_node(id) {
|
||||
fn hir_opt_ident(self, id: HirId) -> Option<Ident> {
|
||||
match self.hir_node(id) {
|
||||
Node::Pat(&Pat { kind: PatKind::Binding(_, _, ident, _), .. }) => Some(ident),
|
||||
// A `Ctor` doesn't have an identifier itself, but its parent
|
||||
// struct/variant does. Compare with `hir::Map::span`.
|
||||
Node::Ctor(..) => match self.tcx.parent_hir_node(id) {
|
||||
Node::Ctor(..) => match self.parent_hir_node(id) {
|
||||
Node::Item(item) => Some(item.ident),
|
||||
Node::Variant(variant) => Some(variant.ident),
|
||||
_ => unreachable!(),
|
||||
|
@ -781,30 +855,32 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn opt_ident_span(self, id: HirId) -> Option<Span> {
|
||||
self.opt_ident(id).map(|ident| ident.span)
|
||||
pub(super) fn hir_opt_ident_span(self, id: HirId) -> Option<Span> {
|
||||
self.hir_opt_ident(id).map(|ident| ident.span)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn ident(self, id: HirId) -> Ident {
|
||||
self.opt_ident(id).unwrap()
|
||||
pub fn hir_ident(self, id: HirId) -> Ident {
|
||||
self.hir_opt_ident(id).unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn opt_name(self, id: HirId) -> Option<Symbol> {
|
||||
self.opt_ident(id).map(|ident| ident.name)
|
||||
pub fn hir_opt_name(self, id: HirId) -> Option<Symbol> {
|
||||
self.hir_opt_ident(id).map(|ident| ident.name)
|
||||
}
|
||||
|
||||
pub fn name(self, id: HirId) -> Symbol {
|
||||
self.opt_name(id).unwrap_or_else(|| bug!("no name for {}", self.node_to_string(id)))
|
||||
pub fn hir_name(self, id: HirId) -> Symbol {
|
||||
self.hir_opt_name(id).unwrap_or_else(|| bug!("no name for {}", self.hir_id_to_string(id)))
|
||||
}
|
||||
|
||||
/// Given a node ID, gets a list of attributes associated with the AST
|
||||
/// corresponding to the node-ID.
|
||||
pub fn attrs(self, id: HirId) -> &'hir [Attribute] {
|
||||
self.tcx.hir_attrs(id.owner).get(id.local_id)
|
||||
pub fn hir_attrs(self, id: HirId) -> &'tcx [Attribute] {
|
||||
self.hir_attr_map(id.owner).get(id.local_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'hir> Map<'hir> {
|
||||
/// Gets the span of the definition of the specified HIR node.
|
||||
/// This is used by `tcx.def_span`.
|
||||
pub fn span(self, hir_id: HirId) -> Span {
|
||||
|
@ -977,12 +1053,6 @@ impl<'hir> Map<'hir> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get a representation of this `id` for debugging purposes.
|
||||
/// NOTE: Do NOT use this in diagnostics!
|
||||
pub fn node_to_string(self, id: HirId) -> String {
|
||||
hir_id_to_string(self, id)
|
||||
}
|
||||
|
||||
/// Returns the HirId of `N` in `struct Foo<const N: usize = { ... }>` when
|
||||
/// called with the HirId for the `{ ... }` anon const
|
||||
pub fn opt_const_param_default_param_def_id(self, anon_const: HirId) -> Option<LocalDefId> {
|
||||
|
@ -1147,102 +1217,6 @@ fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
|
|||
upstream_crates
|
||||
}
|
||||
|
||||
fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
|
||||
let path_str = |def_id: LocalDefId| map.tcx.def_path_str(def_id);
|
||||
|
||||
let span_str = || map.tcx.sess.source_map().span_to_snippet(map.span(id)).unwrap_or_default();
|
||||
let node_str = |prefix| format!("{id} ({prefix} `{}`)", span_str());
|
||||
|
||||
match map.tcx.hir_node(id) {
|
||||
Node::Item(item) => {
|
||||
let item_str = match item.kind {
|
||||
ItemKind::ExternCrate(..) => "extern crate",
|
||||
ItemKind::Use(..) => "use",
|
||||
ItemKind::Static(..) => "static",
|
||||
ItemKind::Const(..) => "const",
|
||||
ItemKind::Fn { .. } => "fn",
|
||||
ItemKind::Macro(..) => "macro",
|
||||
ItemKind::Mod(..) => "mod",
|
||||
ItemKind::ForeignMod { .. } => "foreign mod",
|
||||
ItemKind::GlobalAsm { .. } => "global asm",
|
||||
ItemKind::TyAlias(..) => "ty",
|
||||
ItemKind::Enum(..) => "enum",
|
||||
ItemKind::Struct(..) => "struct",
|
||||
ItemKind::Union(..) => "union",
|
||||
ItemKind::Trait(..) => "trait",
|
||||
ItemKind::TraitAlias(..) => "trait alias",
|
||||
ItemKind::Impl { .. } => "impl",
|
||||
};
|
||||
format!("{id} ({item_str} {})", path_str(item.owner_id.def_id))
|
||||
}
|
||||
Node::ForeignItem(item) => {
|
||||
format!("{id} (foreign item {})", path_str(item.owner_id.def_id))
|
||||
}
|
||||
Node::ImplItem(ii) => {
|
||||
let kind = match ii.kind {
|
||||
ImplItemKind::Const(..) => "associated constant",
|
||||
ImplItemKind::Fn(fn_sig, _) => match fn_sig.decl.implicit_self {
|
||||
ImplicitSelfKind::None => "associated function",
|
||||
_ => "method",
|
||||
},
|
||||
ImplItemKind::Type(_) => "associated type",
|
||||
};
|
||||
format!("{id} ({kind} `{}` in {})", ii.ident, path_str(ii.owner_id.def_id))
|
||||
}
|
||||
Node::TraitItem(ti) => {
|
||||
let kind = match ti.kind {
|
||||
TraitItemKind::Const(..) => "associated constant",
|
||||
TraitItemKind::Fn(fn_sig, _) => match fn_sig.decl.implicit_self {
|
||||
ImplicitSelfKind::None => "associated function",
|
||||
_ => "trait method",
|
||||
},
|
||||
TraitItemKind::Type(..) => "associated type",
|
||||
};
|
||||
|
||||
format!("{id} ({kind} `{}` in {})", ti.ident, path_str(ti.owner_id.def_id))
|
||||
}
|
||||
Node::Variant(variant) => {
|
||||
format!("{id} (variant `{}` in {})", variant.ident, path_str(variant.def_id))
|
||||
}
|
||||
Node::Field(field) => {
|
||||
format!("{id} (field `{}` in {})", field.ident, path_str(field.def_id))
|
||||
}
|
||||
Node::AnonConst(_) => node_str("const"),
|
||||
Node::ConstBlock(_) => node_str("const"),
|
||||
Node::ConstArg(_) => node_str("const"),
|
||||
Node::Expr(_) => node_str("expr"),
|
||||
Node::ExprField(_) => node_str("expr field"),
|
||||
Node::Stmt(_) => node_str("stmt"),
|
||||
Node::PathSegment(_) => node_str("path segment"),
|
||||
Node::Ty(_) => node_str("type"),
|
||||
Node::AssocItemConstraint(_) => node_str("assoc item constraint"),
|
||||
Node::TraitRef(_) => node_str("trait ref"),
|
||||
Node::OpaqueTy(_) => node_str("opaque type"),
|
||||
Node::Pat(_) => node_str("pat"),
|
||||
Node::TyPat(_) => node_str("pat ty"),
|
||||
Node::PatField(_) => node_str("pattern field"),
|
||||
Node::PatExpr(_) => node_str("pattern literal"),
|
||||
Node::Param(_) => node_str("param"),
|
||||
Node::Arm(_) => node_str("arm"),
|
||||
Node::Block(_) => node_str("block"),
|
||||
Node::Infer(_) => node_str("infer"),
|
||||
Node::LetStmt(_) => node_str("local"),
|
||||
Node::Ctor(ctor) => format!(
|
||||
"{id} (ctor {})",
|
||||
ctor.ctor_def_id().map_or("<missing path>".into(), |def_id| path_str(def_id)),
|
||||
),
|
||||
Node::Lifetime(_) => node_str("lifetime"),
|
||||
Node::GenericParam(param) => {
|
||||
format!("{id} (generic_param {})", path_str(param.def_id))
|
||||
}
|
||||
Node::Crate(..) => String::from("(root_crate)"),
|
||||
Node::WherePredicate(_) => node_str("where predicate"),
|
||||
Node::Synthetic => unreachable!(),
|
||||
Node::Err(_) => node_str("error"),
|
||||
Node::PreciseCapturingNonLifetimeArg(_param) => node_str("parameter"),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> ModuleItems {
|
||||
let mut collector = ItemCollector::new(tcx, false);
|
||||
|
||||
|
|
|
@ -202,13 +202,13 @@ pub fn provide(providers: &mut Providers) {
|
|||
}
|
||||
})
|
||||
};
|
||||
providers.hir_attrs = |tcx, id| {
|
||||
providers.hir_attr_map = |tcx, id| {
|
||||
tcx.hir_crate(()).owners[id.def_id].as_owner().map_or(AttributeMap::EMPTY, |o| &o.attrs)
|
||||
};
|
||||
providers.def_span = |tcx, def_id| tcx.hir().span(tcx.local_def_id_to_hir_id(def_id));
|
||||
providers.def_ident_span = |tcx, def_id| {
|
||||
let hir_id = tcx.local_def_id_to_hir_id(def_id);
|
||||
tcx.hir().opt_ident_span(hir_id)
|
||||
tcx.hir_opt_ident_span(hir_id)
|
||||
};
|
||||
providers.fn_arg_names = |tcx, def_id| {
|
||||
let hir = tcx.hir();
|
||||
|
|
|
@ -1200,7 +1200,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||
&& let Some(upvars) = tcx.upvars_mentioned(def_id)
|
||||
{
|
||||
for (&var_id, place) in iter::zip(upvars.keys(), places) {
|
||||
let var_name = tcx.hir().name(var_id);
|
||||
let var_name = tcx.hir_name(var_id);
|
||||
struct_fmt.field(var_name.as_str(), place);
|
||||
}
|
||||
} else {
|
||||
|
@ -1221,7 +1221,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
|||
&& let Some(upvars) = tcx.upvars_mentioned(def_id)
|
||||
{
|
||||
for (&var_id, place) in iter::zip(upvars.keys(), places) {
|
||||
let var_name = tcx.hir().name(var_id);
|
||||
let var_name = tcx.hir_name(var_id);
|
||||
struct_fmt.field(var_name.as_str(), place);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -198,7 +198,7 @@ rustc_queries! {
|
|||
///
|
||||
/// This can be conveniently accessed by methods on `tcx.hir()`.
|
||||
/// Avoid calling this query directly.
|
||||
query hir_attrs(key: hir::OwnerId) -> &'tcx hir::AttributeMap<'tcx> {
|
||||
query hir_attr_map(key: hir::OwnerId) -> &'tcx hir::AttributeMap<'tcx> {
|
||||
desc { |tcx| "getting HIR owner attributes in `{}`", tcx.def_path_str(key) }
|
||||
feedable
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ impl OverlapMode {
|
|||
.as_local()
|
||||
.into_iter()
|
||||
.flat_map(|local_def_id| {
|
||||
tcx.hir().attrs(tcx.local_def_id_to_hir_id(local_def_id))
|
||||
tcx.hir_attrs(tcx.local_def_id_to_hir_id(local_def_id))
|
||||
})
|
||||
.find(|attr| attr.has_name(sym::rustc_strict_coherence))
|
||||
.map(|attr| attr.span());
|
||||
|
|
|
@ -296,7 +296,7 @@ pub struct CaptureInfo {
|
|||
|
||||
pub fn place_to_string_for_capture<'tcx>(tcx: TyCtxt<'tcx>, place: &HirPlace<'tcx>) -> String {
|
||||
let mut curr_string: String = match place.base {
|
||||
HirPlaceBase::Upvar(upvar_id) => tcx.hir().name(upvar_id.var_path.hir_id).to_string(),
|
||||
HirPlaceBase::Upvar(upvar_id) => tcx.hir_name(upvar_id.var_path.hir_id).to_string(),
|
||||
_ => bug!("Capture_information should only contain upvars"),
|
||||
};
|
||||
|
||||
|
|
|
@ -1299,7 +1299,7 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
|
|||
),
|
||||
bodies,
|
||||
})));
|
||||
self.feed_owner_id().hir_attrs(attrs);
|
||||
self.feed_owner_id().hir_attr_map(attrs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2214,7 +2214,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
/// Returns the origin of the opaque type `def_id`.
|
||||
#[instrument(skip(self), level = "trace", ret)]
|
||||
pub fn local_opaque_ty_origin(self, def_id: LocalDefId) -> hir::OpaqueTyOrigin<LocalDefId> {
|
||||
self.hir().expect_opaque_ty(def_id).origin
|
||||
self.hir_expect_opaque_ty(def_id).origin
|
||||
}
|
||||
|
||||
pub fn finish(self) {
|
||||
|
@ -3118,9 +3118,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
|
||||
pub fn late_bound_vars(self, id: HirId) -> &'tcx List<ty::BoundVariableKind> {
|
||||
self.mk_bound_variable_kinds(
|
||||
&self.late_bound_vars_map(id.owner).get(&id.local_id).cloned().unwrap_or_else(|| {
|
||||
bug!("No bound vars found for {}", self.hir().node_to_string(id))
|
||||
}),
|
||||
&self
|
||||
.late_bound_vars_map(id.owner)
|
||||
.get(&id.local_id)
|
||||
.cloned()
|
||||
.unwrap_or_else(|| bug!("No bound vars found for {}", self.hir_id_to_string(id))),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1696,7 +1696,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
// FIXME(@lcnr): Remove this function.
|
||||
pub fn get_attrs_unchecked(self, did: DefId) -> &'tcx [hir::Attribute] {
|
||||
if let Some(did) = did.as_local() {
|
||||
self.hir().attrs(self.local_def_id_to_hir_id(did))
|
||||
self.hir_attrs(self.local_def_id_to_hir_id(did))
|
||||
} else {
|
||||
self.attrs_for_def(did)
|
||||
}
|
||||
|
@ -1720,7 +1720,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
) -> impl Iterator<Item = &'tcx hir::Attribute> {
|
||||
let did: DefId = did.into();
|
||||
if let Some(did) = did.as_local() {
|
||||
self.hir().attrs(self.local_def_id_to_hir_id(did)).iter()
|
||||
self.hir_attrs(self.local_def_id_to_hir_id(did)).iter()
|
||||
} else {
|
||||
self.attrs_for_def(did).iter()
|
||||
}
|
||||
|
@ -1764,7 +1764,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
) -> impl Iterator<Item = &'tcx hir::Attribute> {
|
||||
let filter_fn = move |a: &&hir::Attribute| a.path_matches(attr);
|
||||
if let Some(did) = did.as_local() {
|
||||
self.hir().attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn)
|
||||
self.hir_attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn)
|
||||
} else {
|
||||
self.attrs_for_def(did).iter().filter(filter_fn)
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ impl<'tcx> fmt::Debug for ty::AdtDef<'tcx> {
|
|||
|
||||
impl fmt::Debug for ty::UpvarId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let name = ty::tls::with(|tcx| tcx.hir().name(self.var_path.hir_id));
|
||||
let name = ty::tls::with(|tcx| tcx.hir_name(self.var_path.hir_id));
|
||||
write!(f, "UpvarId({:?};`{}`;{:?})", self.var_path.hir_id, name, self.closure_expr_id)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,7 +310,7 @@ impl<'tcx> TypeckResults<'tcx> {
|
|||
|
||||
pub fn node_type(&self, id: HirId) -> Ty<'tcx> {
|
||||
self.node_type_opt(id).unwrap_or_else(|| {
|
||||
bug!("node_type: no type for node {}", tls::with(|tcx| tcx.hir().node_to_string(id)))
|
||||
bug!("node_type: no type for node {}", tls::with(|tcx| tcx.hir_id_to_string(id)))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -554,7 +554,7 @@ fn invalid_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: HirId) {
|
|||
ty::tls::with(|tcx| {
|
||||
bug!(
|
||||
"node {} cannot be placed in TypeckResults with hir_owner {:?}",
|
||||
tcx.hir().node_to_string(hir_id),
|
||||
tcx.hir_id_to_string(hir_id),
|
||||
hir_owner
|
||||
)
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue