Skip to content

Commit 7293def

Browse files
committed
Rename hir::map::local_def_id_from_hir_id to local_def_id
1 parent a9f8d3a commit 7293def

20 files changed

+28
-28
lines changed

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CognitiveComplexity {
118118
span: Span,
119119
hir_id: HirId,
120120
) {
121-
let def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
121+
let def_id = cx.tcx.hir().local_def_id(hir_id);
122122
if !cx.tcx.has_attr(def_id, sym!(test)) {
123123
self.check(cx, body, span);
124124
}

clippy_lints/src/copy_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare_lint_pass!(CopyIterator => [COPY_ITERATOR]);
3434
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {
3535
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
3636
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
37-
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
37+
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
3838

3939
if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {
4040
span_note_and_lint(

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ declare_lint_pass!(Derive => [EXPL_IMPL_CLONE_ON_COPY, DERIVE_HASH_XOR_EQ]);
6767
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
6868
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
6969
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.node {
70-
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id_from_hir_id(item.hir_id));
70+
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
7171
let is_automatically_derived = is_automatically_derived(&*item.attrs);
7272

7373
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);

clippy_lints/src/empty_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare_lint_pass!(EmptyEnum => [EMPTY_ENUM]);
2727

2828
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
2929
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) {
30-
let did = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
30+
let did = cx.tcx.hir().local_def_id(item.hir_id);
3131
if let ItemKind::Enum(..) = item.node {
3232
let ty = cx.tcx.type_of(did);
3333
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");

clippy_lints/src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
7777
too_large_for_stack: self.too_large_for_stack,
7878
};
7979

80-
let fn_def_id = cx.tcx.hir().local_def_id_from_hir_id(hir_id);
80+
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
8181
let region_scope_tree = &cx.tcx.region_scope_tree(fn_def_id);
8282
ExprUseVisitor::new(
8383
&mut v,

clippy_lints/src/fallible_impl_from.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ declare_lint_pass!(FallibleImplFrom => [FALLIBLE_IMPL_FROM]);
3333
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
3434
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
3535
// check for `impl From<???> for ..`
36-
let impl_def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
36+
let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id);
3737
if_chain! {
3838
if let hir::ItemKind::Impl(.., ref impl_items) = item.node;
3939
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
@@ -95,7 +95,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
9595
then {
9696
// check the body for `begin_panic` or `unwrap`
9797
let body = cx.tcx.hir().body(body_id);
98-
let impl_item_def_id = cx.tcx.hir().local_def_id_from_hir_id(impl_item.id.hir_id);
98+
let impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.id.hir_id);
9999
let mut fpu = FindPanicUnwrap {
100100
lcx: cx,
101101
tables: cx.tcx.typeck_tables_of(impl_item_def_id),

clippy_lints/src/large_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl_lint_pass!(LargeEnumVariant => [LARGE_ENUM_VARIANT]);
4646

4747
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
4848
fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) {
49-
let did = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
49+
let did = cx.tcx.hir().local_def_id(item.hir_id);
5050
if let ItemKind::Enum(ref def, _) = item.node {
5151
let ty = cx.tcx.type_of(did);
5252
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");

clippy_lints/src/len_zero.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item, trait_items
122122
item.ident.name.as_str() == name
123123
&& if let AssocItemKind::Method { has_self } = item.kind {
124124
has_self && {
125-
let did = cx.tcx.hir().local_def_id_from_hir_id(item.id.hir_id);
125+
let did = cx.tcx.hir().local_def_id(item.id.hir_id);
126126
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
127127
}
128128
} else {
@@ -141,7 +141,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item, trait_items
141141

142142
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
143143
let mut current_and_super_traits = FxHashSet::default();
144-
let visited_trait_def_id = cx.tcx.hir().local_def_id_from_hir_id(visited_trait.hir_id);
144+
let visited_trait_def_id = cx.tcx.hir().local_def_id(visited_trait.hir_id);
145145
fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);
146146

147147
let is_empty_method_found = current_and_super_traits
@@ -173,7 +173,7 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item, impl_items: &[ImplIte
173173
item.ident.name.as_str() == name
174174
&& if let AssocItemKind::Method { has_self } = item.kind {
175175
has_self && {
176-
let did = cx.tcx.hir().local_def_id_from_hir_id(item.id.hir_id);
176+
let did = cx.tcx.hir().local_def_id(item.id.hir_id);
177177
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
178178
}
179179
} else {
@@ -193,7 +193,7 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item, impl_items: &[ImplIte
193193

194194
if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
195195
if cx.access_levels.is_exported(i.id.hir_id) {
196-
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
196+
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
197197
let ty = cx.tcx.type_of(def_id);
198198

199199
span_lint(

clippy_lints/src/loops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ fn check_for_loop_range<'a, 'tcx>(
11021102
// ensure that the indexed variable was declared before the loop, see #601
11031103
if let Some(indexed_extent) = indexed_extent {
11041104
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
1105-
let parent_def_id = cx.tcx.hir().local_def_id_from_hir_id(parent_id);
1105+
let parent_def_id = cx.tcx.hir().local_def_id(parent_id);
11061106
let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id);
11071107
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id);
11081108
if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) {
@@ -1792,7 +1792,7 @@ impl<'a, 'tcx> VarVisitor<'a, 'tcx> {
17921792
match res {
17931793
Res::Local(hir_id) => {
17941794
let parent_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
1795-
let parent_def_id = self.cx.tcx.hir().local_def_id_from_hir_id(parent_id);
1795+
let parent_def_id = self.cx.tcx.hir().local_def_id(parent_id);
17961796
let extent = self.cx.tcx.region_scope_tree(parent_def_id).var_scope(hir_id.local_id);
17971797
if indexed_indirectly {
17981798
self.indexed_indirectly.insert(seqvar.segments[0].ident.name, Some(extent));

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
948948
let name = implitem.ident.name.as_str();
949949
let parent = cx.tcx.hir().get_parent_item(implitem.hir_id);
950950
let item = cx.tcx.hir().expect_item(parent);
951-
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
951+
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
952952
let ty = cx.tcx.type_of(def_id);
953953
if_chain! {
954954
if let hir::ImplItemKind::Method(ref sig, id) = implitem.node;

0 commit comments

Comments
 (0)