Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c2d75cf

Browse files
committed
Move methods from Map to TyCtxt, part 3.
Continuing the work from rust-lang#137162. Every method gains a `hir_` prefix.
1 parent a81c264 commit c2d75cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+96
-108
lines changed

clippy_lints/src/assigning_clones.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
107107
&& !cx.tcx.is_builtin_derived(resolved_impl)
108108
// Don't suggest calling a function we're implementing.
109109
&& resolved_impl.as_local().is_none_or(|block_id| {
110-
cx.tcx.hir().parent_owner_iter(e.hir_id).all(|(id, _)| id.def_id != block_id)
110+
cx.tcx.hir_parent_owner_iter(e.hir_id).all(|(id, _)| id.def_id != block_id)
111111
})
112112
&& let resolved_assoc_items = cx.tcx.associated_items(resolved_impl)
113113
// Only suggest if `clone_from`/`clone_into` is explicitly implemented

clippy_lints/src/doc/missing_headers.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ pub fn check(
2424
if !check_private_items
2525
&& cx
2626
.tcx
27-
.hir()
28-
.parent_iter(owner_id.into())
27+
.hir_parent_iter(owner_id.into())
2928
.any(|(id, _node)| is_doc_hidden(cx.tcx.hir().attrs(id)))
3029
{
3130
return;

clippy_lints/src/doc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> {
10571057
"assert" | "assert_eq" | "assert_ne"
10581058
)
10591059
{
1060-
self.is_const = self.cx.tcx.hir().is_inside_const_context(expr.hir_id);
1060+
self.is_const = self.cx.tcx.hir_is_inside_const_context(expr.hir_id);
10611061
self.panic_span = Some(macro_call.span);
10621062
}
10631063
}

clippy_lints/src/escape.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
8080

8181
let parent_id = cx
8282
.tcx
83-
.hir()
84-
.get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
83+
.hir_get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
8584
.def_id;
8685

8786
let mut trait_self_ty = None;

clippy_lints/src/exit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for Exit {
4747
&& let ExprKind::Path(ref path) = path_expr.kind
4848
&& let Some(def_id) = cx.qpath_res(path, path_expr.hir_id).opt_def_id()
4949
&& cx.tcx.is_diagnostic_item(sym::process_exit, def_id)
50-
&& let parent = cx.tcx.hir().get_parent_item(e.hir_id)
50+
&& let parent = cx.tcx.hir_get_parent_item(e.hir_id)
5151
&& let OwnerNode::Item(Item{kind: ItemKind::Fn{ .. }, ..}) = cx.tcx.hir_owner_node(parent)
5252
// If the next item up is a function we check if it is an entry point
5353
// and only then emit a linter warning

clippy_lints/src/indexing_slicing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl IndexingSlicing {
112112
impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
113113
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
114114
if let ExprKind::Index(array, index, _) = &expr.kind
115-
&& (!self.suppress_restriction_lint_in_const || !cx.tcx.hir().is_inside_const_context(expr.hir_id))
115+
&& (!self.suppress_restriction_lint_in_const || !cx.tcx.hir_is_inside_const_context(expr.hir_id))
116116
&& let expr_ty = cx.typeck_results().expr_ty(array)
117117
&& let mut deref = deref_chain(cx, expr_ty)
118118
&& deref.any(|l| {
@@ -181,7 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
181181
span_lint_and_then(cx, INDEXING_SLICING, expr.span, "slicing may panic", |diag| {
182182
diag.help(help_msg);
183183

184-
if cx.tcx.hir().is_inside_const_context(expr.hir_id) {
184+
if cx.tcx.hir_is_inside_const_context(expr.hir_id) {
185185
diag.note(note);
186186
}
187187
});
@@ -223,7 +223,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
223223
span_lint_and_then(cx, INDEXING_SLICING, expr.span, "indexing may panic", |diag| {
224224
diag.help("consider using `.get(n)` or `.get_mut(n)` instead");
225225

226-
if cx.tcx.hir().is_inside_const_context(expr.hir_id) {
226+
if cx.tcx.hir_is_inside_const_context(expr.hir_id) {
227227
diag.note(note);
228228
}
229229
});

clippy_lints/src/large_stack_arrays.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays {
8383
&& let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind()
8484
&& let Some(element_count) = cst.try_to_target_usize(cx.tcx)
8585
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
86-
&& !cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, node)| {
86+
&& !cx.tcx.hir_parent_iter(expr.hir_id).any(|(_, node)| {
8787
matches!(
8888
node,
8989
Node::Item(Item {

clippy_lints/src/loops/infinite_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(super) fn check<'tcx>(
6161
}
6262

6363
fn get_parent_fn_ret_ty<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> Option<FnRetTy<'tcx>> {
64-
for (_, parent_node) in cx.tcx.hir().parent_iter(expr.hir_id) {
64+
for (_, parent_node) in cx.tcx.hir_parent_iter(expr.hir_id) {
6565
match parent_node {
6666
// Skip `Coroutine` closures, these are the body of `async fn`, not async closures.
6767
// This is because we still need to backtrack one parent node to get the `OpaqueDef` ty.

clippy_lints/src/loops/manual_find.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn last_stmt_and_ret<'tcx>(
134134
}
135135
None
136136
}
137-
let mut parent_iter = cx.tcx.hir().parent_iter(expr.hir_id);
137+
let mut parent_iter = cx.tcx.hir_parent_iter(expr.hir_id);
138138
if let Some((node_hir, Node::Stmt(..))) = parent_iter.next()
139139
// This should be the loop
140140
// This should be the function body

clippy_lints/src/loops/needless_range_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub(super) fn check<'tcx>(
5656

5757
// ensure that the indexed variable was declared before the loop, see #601
5858
if let Some(indexed_extent) = indexed_extent {
59-
let parent_def_id = cx.tcx.hir().get_parent_item(expr.hir_id);
59+
let parent_def_id = cx.tcx.hir_get_parent_item(expr.hir_id);
6060
let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id);
6161
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id).unwrap();
6262
if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) {
@@ -256,7 +256,7 @@ impl<'tcx> VarVisitor<'_, 'tcx> {
256256
let res = self.cx.qpath_res(seqpath, seqexpr.hir_id);
257257
match res {
258258
Res::Local(hir_id) => {
259-
let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
259+
let parent_def_id = self.cx.tcx.hir_get_parent_item(expr.hir_id);
260260
let extent = self
261261
.cx
262262
.tcx

0 commit comments

Comments
 (0)