mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Tweak signatures in rustc_middle::hir::map.
This commit is contained in:
parent
cc9b259b5e
commit
0ff1d1e122
@ -117,7 +117,7 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) {
|
fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) {
|
||||||
let node = tcx.hir().expect_owner(def_id);
|
let node = tcx.hir().owner(def_id);
|
||||||
match node {
|
match node {
|
||||||
hir::OwnerNode::Crate(_) => {}
|
hir::OwnerNode::Crate(_) => {}
|
||||||
hir::OwnerNode::Item(item) => check_item(tcx, item),
|
hir::OwnerNode::Item(item) => check_item(tcx, item),
|
||||||
|
@ -163,7 +163,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
|
|||||||
// Otherwise, we need to visit the attributes in source code order, so we fetch HIR and do
|
// Otherwise, we need to visit the attributes in source code order, so we fetch HIR and do
|
||||||
// a standard visit.
|
// a standard visit.
|
||||||
// FIXME(#102522) Just iterate on attrs once that iteration order matches HIR's.
|
// FIXME(#102522) Just iterate on attrs once that iteration order matches HIR's.
|
||||||
_ => match tcx.hir().expect_owner(owner) {
|
_ => match tcx.hir().owner(owner) {
|
||||||
hir::OwnerNode::Item(item) => levels.visit_item(item),
|
hir::OwnerNode::Item(item) => levels.visit_item(item),
|
||||||
hir::OwnerNode::ForeignItem(item) => levels.visit_foreign_item(item),
|
hir::OwnerNode::ForeignItem(item) => levels.visit_foreign_item(item),
|
||||||
hir::OwnerNode::TraitItem(item) => levels.visit_trait_item(item),
|
hir::OwnerNode::TraitItem(item) => levels.visit_trait_item(item),
|
||||||
|
@ -353,6 +353,10 @@ impl<'hir> Map<'hir> {
|
|||||||
node.node.generics()
|
node.node.generics()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn owner(self, id: OwnerId) -> OwnerNode<'hir> {
|
||||||
|
self.tcx.hir_owner(id).unwrap_or_else(|| bug!("expected owner for {:?}", id)).node
|
||||||
|
}
|
||||||
|
|
||||||
pub fn item(self, id: ItemId) -> &'hir Item<'hir> {
|
pub fn item(self, id: ItemId) -> &'hir Item<'hir> {
|
||||||
self.tcx.hir_owner(id.owner_id).unwrap().node.expect_item()
|
self.tcx.hir_owner(id.owner_id).unwrap().node.expect_item()
|
||||||
}
|
}
|
||||||
@ -822,8 +826,11 @@ impl<'hir> Map<'hir> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expect_owner(self, id: OwnerId) -> OwnerNode<'hir> {
|
pub fn expect_owner(self, def_id: LocalDefId) -> OwnerNode<'hir> {
|
||||||
self.tcx.hir_owner(id).unwrap_or_else(|| bug!("expected owner for {:?}", id)).node
|
self.tcx
|
||||||
|
.hir_owner(OwnerId { def_id })
|
||||||
|
.unwrap_or_else(|| bug!("expected owner for {:?}", def_id))
|
||||||
|
.node
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expect_item(self, id: LocalDefId) -> &'hir Item<'hir> {
|
pub fn expect_item(self, id: LocalDefId) -> &'hir Item<'hir> {
|
||||||
|
Loading…
Reference in New Issue
Block a user