Skip to content

Commit 9e3bb89

Browse files
committed
Auto merge of rust-lang#120346 - petrochenkov:ownodes, r=oli-obk
hir: Refactor getters for owner nodes
2 parents f0dbf68 + 233c8c9 commit 9e3bb89

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

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)

clippy_lints/src/min_ident_chars.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ impl Visitor<'_> for IdentVisitor<'_, '_> {
9393
// reimplement it even if we wanted to
9494
cx.tcx.opt_hir_node(hir_id)
9595
} else {
96-
let Some(owner) = cx.tcx.hir_owner_nodes(hir_id.owner).as_owner() else {
97-
return;
98-
};
96+
let owner = cx.tcx.hir_owner_nodes(hir_id.owner);
9997
owner.nodes.get(hir_id.local_id).copied().flatten().map(|p| p.node)
10098
};
10199
let Some(node) = node else {

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)