Skip to content

Commit fc9bc33

Browse files
committed
Only store a LocalDefId in hir::TraitItem.
1 parent 2dc6539 commit fc9bc33

File tree

9 files changed

+15
-19
lines changed

9 files changed

+15
-19
lines changed

clippy_lints/src/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
246246
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
247247
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
248248
if !in_external_macro(cx.tcx.sess, item.span) {
249-
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None, None);
249+
lint_for_missing_headers(cx, item.hir_id(), item.span, sig, headers, None, None);
250250
}
251251
}
252252
}

clippy_lints/src/escape.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
8787
// find `self` ty for this trait if relevant
8888
if let ItemKind::Trait(_, _, _, _, items) = item.kind {
8989
for trait_item in items {
90-
if trait_item.id.hir_id == hir_id {
90+
if trait_item.id.hir_id() == hir_id {
9191
// be sure we have `self` parameter in this function
9292
if let AssocItemKind::Fn { has_self: true } = trait_item.kind {
9393
trait_self_ty =
94-
Some(TraitRef::identity(cx.tcx, trait_item.id.hir_id.owner.to_def_id()).self_ty());
94+
Some(TraitRef::identity(cx.tcx, trait_item.id.def_id.to_def_id()).self_ty());
9595
}
9696
}
9797
}

clippy_lints/src/functions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,27 +339,27 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
339339
if sig.header.abi == Abi::Rust {
340340
self.check_arg_number(cx, &sig.decl, item.span.with_hi(sig.decl.output.span().hi()));
341341
}
342-
let is_public = cx.access_levels.is_exported(item.hir_id);
342+
let is_public = cx.access_levels.is_exported(item.hir_id());
343343
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
344344
if is_public {
345345
check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
346346
}
347347

348348
let attr = must_use_attr(&item.attrs);
349349
if let Some(attr) = attr {
350-
check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr);
350+
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
351351
}
352352
if let hir::TraitFn::Provided(eid) = *eid {
353353
let body = cx.tcx.hir().body(eid);
354-
Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id);
354+
Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id());
355355

356356
if attr.is_none() && is_public && !is_proc_macro(cx.sess(), &item.attrs) {
357357
check_must_use_candidate(
358358
cx,
359359
&sig.decl,
360360
body,
361361
item.span,
362-
item.hir_id,
362+
item.hir_id(),
363363
item.span.with_hi(sig.decl.output.span().hi()),
364364
"this method could have a `#[must_use]` attribute",
365365
);

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
159159
fn is_named_self(cx: &LateContext<'_>, item: &TraitItemRef, name: &str) -> bool {
160160
item.ident.name.as_str() == name
161161
&& if let AssocItemKind::Fn { has_self } = item.kind {
162-
has_self && {
163-
let did = cx.tcx.hir().local_def_id(item.id.hir_id);
164-
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
165-
}
162+
has_self && { cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1 }
166163
} else {
167164
false
168165
}

clippy_lints/src/methods/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
17911791
if let Some(first_arg_ty) = sig.decl.inputs.iter().next();
17921792
let first_arg_span = first_arg_ty.span;
17931793
let first_arg_ty = hir_ty_to_ty(cx.tcx, first_arg_ty);
1794-
let self_ty = TraitRef::identity(cx.tcx, item.hir_id.owner.to_def_id()).self_ty();
1794+
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty();
17951795

17961796
then {
17971797
lint_wrong_self_convention(cx, &item.ident.name.as_str(), false, self_ty, first_arg_ty, first_arg_span);
@@ -1801,8 +1801,8 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
18011801
if_chain! {
18021802
if item.ident.name == sym::new;
18031803
if let TraitItemKind::Fn(_, _) = item.kind;
1804-
let ret_ty = return_ty(cx, item.hir_id);
1805-
let self_ty = TraitRef::identity(cx.tcx, item.hir_id.owner.to_def_id()).self_ty();
1804+
let ret_ty = return_ty(cx, item.hir_id());
1805+
let self_ty = TraitRef::identity(cx.tcx, item.def_id.to_def_id()).self_ty();
18061806
if !contains_ty(ret_ty, self_ty);
18071807

18081808
then {

clippy_lints/src/missing_doc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
164164
}
165165

166166
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx hir::TraitItem<'_>) {
167-
let def_id = cx.tcx.hir().local_def_id(trait_item.hir_id);
168-
let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id());
167+
let (article, desc) = cx.tcx.article_and_description(trait_item.def_id.to_def_id());
169168

170169
self.check_missing_docs_attrs(cx, &trait_item.attrs, trait_item.span, article, desc);
171170
}

clippy_lints/src/mut_key.rs

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

7272
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'tcx>) {
7373
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
74-
check_sig(cx, item.hir_id, &sig.decl);
74+
check_sig(cx, item.hir_id(), &sig.decl);
7575
}
7676
}
7777

clippy_lints/src/pass_by_ref_or_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
206206
}
207207

208208
if let hir::TraitItemKind::Fn(method_sig, _) = &item.kind {
209-
self.check_poly_fn(cx, item.hir_id, &*method_sig.decl, None);
209+
self.check_poly_fn(cx, item.hir_id(), &*method_sig.decl, None);
210210
}
211211
}
212212

clippy_lints/src/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
147147
} else {
148148
None
149149
};
150-
check_fn(cx, &sig.decl, item.hir_id, body_id);
150+
check_fn(cx, &sig.decl, item.hir_id(), body_id);
151151
}
152152
}
153153

0 commit comments

Comments
 (0)