Skip to content

Commit db41f4a

Browse files
committed
hir: Remove hir::Map::{owner,expect_owner}
1 parent 667d5d3 commit db41f4a

File tree

10 files changed

+11
-19
lines changed

10 files changed

+11
-19
lines changed

compiler/rustc_hir_analysis/src/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ pub fn check_function_signature<'tcx>(
578578
fn_id: LocalDefId,
579579
) -> rustc_span::Span {
580580
let mut args = {
581-
let node = tcx.hir().expect_owner(fn_id);
581+
let node = tcx.expect_hir_owner_node(fn_id);
582582
let decl = node.fn_decl().unwrap_or_else(|| bug!("expected fn decl, found {:?}", node));
583583
decl.inputs.iter().map(|t| t.span).chain(std::iter::once(decl.output.span()))
584584
};

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ where
189189
}
190190

191191
fn check_well_formed(tcx: TyCtxt<'_>, def_id: hir::OwnerId) -> Result<(), ErrorGuaranteed> {
192-
let node = tcx.hir().owner(def_id);
192+
let node = tcx.hir_owner_node(def_id);
193193
let mut res = match node {
194194
hir::OwnerNode::Crate(_) => bug!("check_well_formed cannot be applied to the crate root"),
195195
hir::OwnerNode::Item(item) => check_item(tcx, item),

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn resolve_bound_vars(tcx: TyCtxt<'_>, local_def_id: hir::OwnerId) -> ResolveBou
254254
map: &mut named_variable_map,
255255
scope: &Scope::Root { opt_parent_item: None },
256256
};
257-
match tcx.hir().owner(local_def_id) {
257+
match tcx.hir_owner_node(local_def_id) {
258258
hir::OwnerNode::Item(item) => visitor.visit_item(item),
259259
hir::OwnerNode::ForeignItem(item) => visitor.visit_foreign_item(item),
260260
hir::OwnerNode::TraitItem(item) => {

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2546,7 +2546,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
25462546
add_lt_suggs,
25472547
new_lt: &new_lt,
25482548
};
2549-
match self.tcx.hir().expect_owner(lifetime_scope) {
2549+
match self.tcx.expect_hir_owner_node(lifetime_scope) {
25502550
hir::OwnerNode::Item(i) => visitor.visit_item(i),
25512551
hir::OwnerNode::ForeignItem(i) => visitor.visit_foreign_item(i),
25522552
hir::OwnerNode::ImplItem(i) => visitor.visit_impl_item(i),

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
443443
if let hir::OwnerNode::Item(Item {
444444
kind: ItemKind::Impl(hir::Impl { self_ty, .. }),
445445
..
446-
}) = tcx.hir().owner(impl_did)
446+
}) = tcx.hir_owner_node(impl_did)
447447
{
448448
Some((impl_item.ident, self_ty))
449449
} else {

compiler/rustc_lint/src/levels.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLe
181181
// Otherwise, we need to visit the attributes in source code order, so we fetch HIR and do
182182
// a standard visit.
183183
// FIXME(#102522) Just iterate on attrs once that iteration order matches HIR's.
184-
_ => match tcx.hir().owner(owner) {
184+
_ => match tcx.hir_owner_node(owner) {
185185
hir::OwnerNode::Item(item) => levels.visit_item(item),
186186
hir::OwnerNode::ForeignItem(item) => levels.visit_foreign_item(item),
187187
hir::OwnerNode::TraitItem(item) => levels.visit_trait_item(item),

compiler/rustc_middle/src/hir/map/mod.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ impl<'tcx> TyCtxt<'tcx> {
148148
}
149149

150150
#[inline]
151-
fn expect_hir_owner_node(self, def_id: LocalDefId) -> OwnerNode<'tcx> {
151+
pub fn expect_hir_owner_node(self, def_id: LocalDefId) -> OwnerNode<'tcx> {
152152
self.expect_hir_owner_nodes(def_id).node()
153153
}
154154

155155
#[inline]
156-
fn hir_owner_node(self, owner_id: OwnerId) -> OwnerNode<'tcx> {
156+
pub fn hir_owner_node(self, owner_id: OwnerId) -> OwnerNode<'tcx> {
157157
self.hir_owner_nodes(owner_id).node()
158158
}
159159

@@ -263,10 +263,6 @@ impl<'hir> Map<'hir> {
263263
self.tcx.opt_hir_owner_node(id)?.generics()
264264
}
265265

266-
pub fn owner(self, id: OwnerId) -> OwnerNode<'hir> {
267-
self.tcx.hir_owner_node(id)
268-
}
269-
270266
pub fn item(self, id: ItemId) -> &'hir Item<'hir> {
271267
self.tcx.hir_owner_node(id.owner_id).expect_item()
272268
}
@@ -755,10 +751,6 @@ impl<'hir> Map<'hir> {
755751
)
756752
}
757753

758-
pub fn expect_owner(self, def_id: LocalDefId) -> OwnerNode<'hir> {
759-
self.tcx.expect_hir_owner_node(def_id)
760-
}
761-
762754
pub fn expect_item(self, id: LocalDefId) -> &'hir Item<'hir> {
763755
match self.tcx.expect_hir_owner_node(id) {
764756
OwnerNode::Item(item) => item,

compiler/rustc_mir_build/src/check_unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ impl UnsafeOpKind {
583583
suggest_unsafe_block: bool,
584584
) {
585585
let parent_id = tcx.hir().get_parent_item(hir_id);
586-
let parent_owner = tcx.hir().owner(parent_id);
586+
let parent_owner = tcx.hir_owner_node(parent_id);
587587
let should_suggest = parent_owner.fn_sig().is_some_and(|sig| sig.header.is_unsafe());
588588
let unsafe_not_inherited_note = if should_suggest {
589589
suggest_unsafe_block.then(|| {

src/tools/clippy/clippy_lints/src/methods/iter_nth_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_span::sym;
1111
use super::ITER_NTH_ZERO;
1212

1313
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>, arg: &hir::Expr<'_>) {
14-
if let OwnerNode::Item(item) = cx.tcx.hir().owner(cx.tcx.hir().get_parent_item(expr.hir_id))
14+
if let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir().get_parent_item(expr.hir_id))
1515
&& let def_id = item.owner_id.to_def_id()
1616
&& is_trait_method(cx, expr, sym::Iterator)
1717
&& let Some(Constant::Int(0)) = constant(cx, cx.typeck_results(), arg)

src/tools/clippy/clippy_lints/src/returns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
183183
&& let ExprKind::Ret(Some(ret)) = expr.kind
184184
&& let ExprKind::Match(.., MatchSource::TryDesugar(_)) = ret.kind
185185
// Ensure this is not the final stmt, otherwise removing it would cause a compile error
186-
&& let OwnerNode::Item(item) = cx.tcx.hir().owner(cx.tcx.hir().get_parent_item(expr.hir_id))
186+
&& let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir().get_parent_item(expr.hir_id))
187187
&& let ItemKind::Fn(_, _, body) = item.kind
188188
&& let block = cx.tcx.hir().body(body).value
189189
&& let ExprKind::Block(block, _) = block.kind

0 commit comments

Comments
 (0)