Skip to content

Commit bf86fe1

Browse files
committed
rustc: hir().local_def_id_to_hir_id() -> tcx.local_def_id_to_hir_id() cleanup
1 parent a79a7d6 commit bf86fe1

24 files changed

+32
-32
lines changed

clippy_lints/src/derive.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ fn check_hash_peq<'tcx>(
255255
"you are deriving `Hash` but have implemented `PartialEq` explicitly",
256256
|diag| {
257257
if let Some(local_def_id) = impl_id.as_local() {
258-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
258+
let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
259259
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialEq` implemented here");
260260
}
261261
},
@@ -299,7 +299,7 @@ fn check_ord_partial_ord<'tcx>(
299299

300300
span_lint_and_then(cx, DERIVE_ORD_XOR_PARTIAL_ORD, span, mess, |diag| {
301301
if let Some(local_def_id) = impl_id.as_local() {
302-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
302+
let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
303303
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialOrd` implemented here");
304304
}
305305
});
@@ -381,7 +381,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
381381
&& match_def_path(cx, trait_def_id, &paths::SERDE_DESERIALIZE)
382382
&& let ty::Adt(def, _) = ty.kind()
383383
&& let Some(local_def_id) = def.did().as_local()
384-
&& let adt_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id)
384+
&& let adt_hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id)
385385
&& !is_lint_allowed(cx, UNSAFE_DERIVE_DESERIALIZE, adt_hir_id)
386386
&& cx
387387
.tcx

clippy_lints/src/error_impl_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for ErrorImplError {
5858
if let Some(trait_def_id) = imp.of_trait.and_then(|t| t.trait_def_id())
5959
&& error_def_id == trait_def_id
6060
&& let Some(def_id) = path_res(cx, imp.self_ty).opt_def_id().and_then(DefId::as_local)
61-
&& let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id)
61+
&& let hir_id = cx.tcx.local_def_id_to_hir_id(def_id)
6262
&& let Some(ident) = cx.tcx.opt_item_ident(def_id.to_def_id())
6363
&& ident.name == sym::Error
6464
&& is_visible_outside_module(cx, def_id) =>

clippy_lints/src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
7474
let parent_id = cx
7575
.tcx
7676
.hir()
77-
.get_parent_item(cx.tcx.hir().local_def_id_to_hir_id(fn_def_id))
77+
.get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
7878
.def_id;
7979
let parent_node = cx.tcx.hir().find_by_def_id(parent_id);
8080

clippy_lints/src/excessive_bools.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
171171
span: Span,
172172
def_id: LocalDefId,
173173
) {
174-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
174+
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
175175
if let Some(fn_header) = fn_kind.header()
176176
&& fn_header.abi == Abi::Rust
177177
&& get_parent_as_impl(cx.tcx, hir_id).map_or(true, |impl_item| impl_item.of_trait.is_none())

clippy_lints/src/functions/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
407407
span: Span,
408408
def_id: LocalDefId,
409409
) {
410-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
410+
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
411411
too_many_arguments::check_fn(cx, kind, decl, span, hir_id, self.too_many_arguments_threshold);
412412
too_many_lines::check_fn(cx, kind, span, body, self.too_many_lines_threshold);
413413
not_unsafe_ptr_arg_deref::check_fn(cx, kind, decl, body, def_id);

clippy_lints/src/future_not_send.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
6262
if let FnKind::Closure = kind {
6363
return;
6464
}
65-
let ret_ty = return_ty(cx, cx.tcx.hir().local_def_id_to_hir_id(fn_def_id).expect_owner());
65+
let ret_ty = return_ty(cx, cx.tcx.local_def_id_to_hir_id(fn_def_id).expect_owner());
6666
if let ty::Alias(ty::Opaque, AliasTy { def_id, args, .. }) = *ret_ty.kind() {
6767
let preds = cx.tcx.explicit_item_bounds(def_id);
6868
let mut is_future = false;

clippy_lints/src/inherent_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
6363
&& !is_lint_allowed(
6464
cx,
6565
MULTIPLE_INHERENT_IMPL,
66-
cx.tcx.hir().local_def_id_to_hir_id(id),
66+
cx.tcx.local_def_id_to_hir_id(id),
6767
)
6868
}) {
6969
for impl_id in impl_ids.iter().map(|id| id.expect_local()) {
@@ -117,7 +117,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
117117

118118
/// Gets the span for the given impl block unless it's not being considered by the lint.
119119
fn get_impl_span(cx: &LateContext<'_>, id: LocalDefId) -> Option<Span> {
120-
let id = cx.tcx.hir().local_def_id_to_hir_id(id);
120+
let id = cx.tcx.local_def_id_to_hir_id(id);
121121
if let Node::Item(&Item {
122122
kind: ItemKind::Impl(impl_item),
123123
span,

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
142142
&& let TyKind::Path(ty_path) = &imp.self_ty.kind
143143
&& let Some(ty_id) = cx.qpath_res(ty_path, imp.self_ty.hir_id).opt_def_id()
144144
&& let Some(local_id) = ty_id.as_local()
145-
&& let ty_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id)
145+
&& let ty_hir_id = cx.tcx.local_def_id_to_hir_id(local_id)
146146
&& !is_lint_allowed(cx, LEN_WITHOUT_IS_EMPTY, ty_hir_id)
147147
&& let Some(output) =
148148
parse_len_output(cx, cx.tcx.fn_sig(item.owner_id).instantiate_identity().skip_binder())

clippy_lints/src/manual_non_exhaustive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualNonExhaustiveEnum {
192192
.contains(&(enum_id.to_def_id(), variant_id.to_def_id()))
193193
})
194194
{
195-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(enum_id);
195+
let hir_id = cx.tcx.local_def_id_to_hir_id(enum_id);
196196
span_lint_hir_and_then(
197197
cx,
198198
MANUAL_NON_EXHAUSTIVE,

clippy_lints/src/methods/filter_map_bool_then.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, arg: &
2727
closure.def_id.to_def_id(),
2828
Binder::bind_with_vars(
2929
cx.typeck_results().node_type(param_ty.hir_id),
30-
cx.tcx.late_bound_vars(cx.tcx.hir().local_def_id_to_hir_id(closure.def_id)),
30+
cx.tcx.late_bound_vars(cx.tcx.local_def_id_to_hir_id(closure.def_id)),
3131
),
3232
)
3333
&& is_copy(cx, param_ty)

clippy_lints/src/missing_const_for_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
131131
FnKind::Closure => return,
132132
}
133133

134-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
134+
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
135135

136136
// Const fns are not allowed as methods in a trait.
137137
{

clippy_lints/src/needless_pass_by_ref_mut.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
137137
return;
138138
}
139139

140-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(fn_def_id);
140+
let hir_id = cx.tcx.local_def_id_to_hir_id(fn_def_id);
141141
let is_async = match kind {
142142
FnKind::ItemFn(.., header) => {
143143
if header.is_unsafe() {
@@ -256,7 +256,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
256256
span_lint_hir_and_then(
257257
cx,
258258
NEEDLESS_PASS_BY_REF_MUT,
259-
cx.tcx.hir().local_def_id_to_hir_id(*fn_def_id),
259+
cx.tcx.local_def_id_to_hir_id(*fn_def_id),
260260
sp,
261261
"this argument is a mutable reference, but not used mutably",
262262
|diag| {

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
8686
return;
8787
}
8888

89-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(fn_def_id);
89+
let hir_id = cx.tcx.local_def_id_to_hir_id(fn_def_id);
9090

9191
match kind {
9292
FnKind::ItemFn(.., header) => {

clippy_lints/src/new_without_default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
106106
let ty = cx.tcx.type_of(d).instantiate_identity();
107107
if let Some(ty_def) = ty.ty_adt_def() {
108108
if let Some(local_def_id) = ty_def.did().as_local() {
109-
impls.insert(cx.tcx.hir().local_def_id_to_hir_id(local_def_id));
109+
impls.insert(cx.tcx.local_def_id_to_hir_id(local_def_id));
110110
}
111111
}
112112
});
@@ -119,7 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
119119
&& let self_def = cx.tcx.type_of(self_def_id).instantiate_identity()
120120
&& let Some(self_def) = self_def.ty_adt_def()
121121
&& let Some(self_local_did) = self_def.did().as_local()
122-
&& let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_local_did)
122+
&& let self_id = cx.tcx.local_def_id_to_hir_id(self_local_did)
123123
&& impling_types.contains(&self_id)
124124
{
125125
return;

clippy_lints/src/non_send_fields_in_send_ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
100100
if let Some(field_hir_id) = field
101101
.did
102102
.as_local()
103-
.map(|local_def_id| hir_map.local_def_id_to_hir_id(local_def_id))
103+
.map(|local_def_id| cx.tcx.local_def_id_to_hir_id(local_def_id))
104104
&& !is_lint_allowed(cx, NON_SEND_FIELDS_IN_SEND_TY, field_hir_id)
105105
&& let field_ty = field.ty(cx.tcx, impl_trait_args)
106106
&& !ty_allowed_in_send(cx, field_ty, send_trait)

clippy_lints/src/panic_in_result_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicInResultFn {
5555
if matches!(fn_kind, FnKind::Closure) {
5656
return;
5757
}
58-
let owner = cx.tcx.hir().local_def_id_to_hir_id(def_id).expect_owner();
58+
let owner = cx.tcx.local_def_id_to_hir_id(def_id).expect_owner();
5959
if is_type_diagnostic_item(cx, return_ty(cx, owner), sym::Result) {
6060
lint_impl_body(cx, span, body);
6161
}

clippy_lints/src/pass_by_ref_or_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
279279
return;
280280
}
281281

282-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
282+
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
283283
match kind {
284284
FnKind::ItemFn(.., header) => {
285285
if header.abi != Abi::Rust {

clippy_lints/src/return_self_not_must_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'tcx> LateLintPass<'tcx> for ReturnSelfNotMustUse {
115115
// `#[must_use]` should be put on the trait definition directly.
116116
&& cx.tcx.trait_id_of_impl(impl_def).is_none()
117117
{
118-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(fn_def);
118+
let hir_id = cx.tcx.local_def_id_to_hir_id(fn_def);
119119
check_method(cx, decl, fn_def, span, hir_id.expect_owner());
120120
}
121121
}

clippy_lints/src/self_named_constructors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors {
7272

7373
if let Some(self_def) = self_ty.ty_adt_def()
7474
&& let Some(self_local_did) = self_def.did().as_local()
75-
&& let self_id = cx.tcx.hir().local_def_id_to_hir_id(self_local_did)
75+
&& let self_id = cx.tcx.local_def_id_to_hir_id(self_local_did)
7676
&& let Some(Node::Item(x)) = cx.tcx.hir().find(self_id)
7777
&& let type_name = x.ident.name.as_str().to_lowercase()
7878
&& (impl_item.ident.name.as_str() == type_name

clippy_lints/src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
324324
let is_in_trait_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find_by_def_id(
325325
cx.tcx
326326
.hir()
327-
.get_parent_item(cx.tcx.hir().local_def_id_to_hir_id(def_id))
327+
.get_parent_item(cx.tcx.local_def_id_to_hir_id(def_id))
328328
.def_id,
329329
) {
330330
matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }))

clippy_lints/src/undocumented_unsafe_blocks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ fn block_parents_have_safety_comment(
349349
span,
350350
owner_id,
351351
..
352-
})) => (*span, cx.tcx.hir().local_def_id_to_hir_id(owner_id.def_id)),
352+
})) => (*span, cx.tcx.local_def_id_to_hir_id(owner_id.def_id)),
353353
_ => {
354354
if is_branchy(expr) {
355355
return false;
@@ -370,7 +370,7 @@ fn block_parents_have_safety_comment(
370370
span,
371371
owner_id,
372372
..
373-
}) => (*span, cx.tcx.hir().local_def_id_to_hir_id(owner_id.def_id)),
373+
}) => (*span, cx.tcx.local_def_id_to_hir_id(owner_id.def_id)),
374374
_ => return false,
375375
};
376376
// if unsafe block is part of a let/const/static statement,

clippy_lints/src/unnecessary_wraps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
9191
}
9292

9393
// Abort if the method is implementing a trait or of it a trait method.
94-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
94+
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
9595
if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) {
9696
if matches!(
9797
item.kind,

clippy_utils/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ pub fn get_trait_def_id(cx: &LateContext<'_>, path: &[&str]) -> Option<DefId> {
709709
/// ```
710710
pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'tcx>, def_id: LocalDefId) -> Option<&'tcx TraitRef<'tcx>> {
711711
// Get the implemented trait for the current function
712-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(def_id);
712+
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
713713
let parent_impl = cx.tcx.hir().get_parent_item(hir_id);
714714
if parent_impl != hir::CRATE_OWNER_ID
715715
&& let hir::Node::Item(item) = cx.tcx.hir().get_by_def_id(parent_impl.def_id)
@@ -2567,7 +2567,7 @@ pub fn inherits_cfg(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
25672567

25682568
tcx.has_attr(def_id, sym::cfg)
25692569
|| hir
2570-
.parent_iter(hir.local_def_id_to_hir_id(def_id))
2570+
.parent_iter(tcx.local_def_id_to_hir_id(def_id))
25712571
.flat_map(|(parent_id, _)| hir.attrs(parent_id))
25722572
.any(|attr| attr.has_name(sym::cfg))
25732573
}
@@ -2687,7 +2687,7 @@ impl<'tcx> ExprUseNode<'tcx> {
26872687
.and(Binder::dummy(cx.tcx.type_of(id).instantiate_identity())),
26882688
)),
26892689
Self::Return(id) => {
2690-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(id.def_id);
2690+
let hir_id = cx.tcx.local_def_id_to_hir_id(id.def_id);
26912691
if let Some(Node::Expr(Expr {
26922692
kind: ExprKind::Closure(c),
26932693
..

clippy_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
694694
ty::Closure(id, subs) => {
695695
let decl = id
696696
.as_local()
697-
.and_then(|id| cx.tcx.hir().fn_decl_by_hir_id(cx.tcx.hir().local_def_id_to_hir_id(id)));
697+
.and_then(|id| cx.tcx.hir().fn_decl_by_hir_id(cx.tcx.local_def_id_to_hir_id(id)));
698698
Some(ExprFnSig::Closure(decl, subs.as_closure().sig()))
699699
},
700700
ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.fn_sig(id).instantiate(cx.tcx, subs), Some(id))),

0 commit comments

Comments
 (0)