Make encode_attrs use opt_local_def_id_to_hir_id so we can feed it with None for definitions that have no HIR
This commit is contained in:
parent
f722b24eb9
commit
833b9154ac
@ -1137,8 +1137,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
is_doc_hidden: false,
|
||||
};
|
||||
let attr_iter = tcx
|
||||
.hir()
|
||||
.attrs(tcx.hir().local_def_id_to_hir_id(def_id))
|
||||
.opt_local_def_id_to_hir_id(def_id)
|
||||
.map_or(Default::default(), |hir_id| tcx.hir().attrs(hir_id))
|
||||
.iter()
|
||||
.filter(|attr| analyze_attr(attr, &mut state));
|
||||
|
||||
|
@ -121,13 +121,13 @@ pub fn provide(providers: &mut Providers) {
|
||||
let node = owner.node();
|
||||
Some(Owner { node, hash_without_bodies: owner.nodes.hash_without_bodies })
|
||||
};
|
||||
providers.local_def_id_to_hir_id = |tcx, id| {
|
||||
providers.opt_local_def_id_to_hir_id = |tcx, id| {
|
||||
let owner = tcx.hir_crate(()).owners[id].map(|_| ());
|
||||
match owner {
|
||||
Some(match owner {
|
||||
MaybeOwner::Owner(_) => HirId::make_owner(id),
|
||||
MaybeOwner::Phantom => bug!("No HirId for {:?}", id),
|
||||
MaybeOwner::NonOwner(hir_id) => hir_id,
|
||||
}
|
||||
})
|
||||
};
|
||||
providers.hir_owner_nodes = |tcx, id| tcx.hir_crate(()).owners[id.def_id].map(|i| &i.nodes);
|
||||
providers.hir_owner_parent = |tcx, id| {
|
||||
|
@ -85,11 +85,10 @@ rustc_queries! {
|
||||
desc { |tcx| "getting HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
}
|
||||
|
||||
/// Gives access to the HIR ID for the given `LocalDefId` owner `key`.
|
||||
/// Gives access to the HIR ID for the given `LocalDefId` owner `key` if any.
|
||||
///
|
||||
/// This can be conveniently accessed by methods on `tcx.hir()`.
|
||||
/// Avoid calling this query directly.
|
||||
query local_def_id_to_hir_id(key: LocalDefId) -> hir::HirId {
|
||||
/// Definitions that were generated with no HIR, would be feeded to return `None`.
|
||||
query opt_local_def_id_to_hir_id(key: LocalDefId) -> Option<hir::HirId>{
|
||||
desc { |tcx| "getting HIR ID of `{}`", tcx.def_path_str(key.to_def_id()) }
|
||||
}
|
||||
|
||||
|
@ -2428,6 +2428,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn local_def_id_to_hir_id(self, local_def_id: LocalDefId) -> HirId {
|
||||
self.opt_local_def_id_to_hir_id(local_def_id).unwrap()
|
||||
}
|
||||
|
||||
pub fn trait_solver_next(self) -> bool {
|
||||
self.sess.opts.unstable_opts.trait_solver == rustc_session::config::TraitSolver::Next
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user