Skip to content

Commit 928e72d

Browse files
committed
Auto merge of #6789 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: None
2 parents ef41f2b + 8f8c7c2 commit 928e72d

39 files changed

+134
-149
lines changed

clippy_lints/src/copy_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<'tcx> LateLintPass<'tcx> for CopyIterator {
3838
..
3939
}) = item.kind
4040
{
41-
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
41+
let ty = cx.tcx.type_of(item.def_id);
4242

4343
if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {
4444
span_lint_and_note(

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
169169
..
170170
}) = item.kind
171171
{
172-
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
172+
let ty = cx.tcx.type_of(item.def_id);
173173
let is_automatically_derived = is_automatically_derived(&*item.attrs);
174174

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

clippy_lints/src/doc.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,23 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
216216
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
217217
match item.kind {
218218
hir::ItemKind::Fn(ref sig, _, body_id) => {
219-
if !(is_entrypoint_fn(cx, cx.tcx.hir().local_def_id(item.hir_id).to_def_id())
220-
|| in_external_macro(cx.tcx.sess, item.span))
221-
{
219+
if !(is_entrypoint_fn(cx, item.def_id.to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) {
222220
let body = cx.tcx.hir().body(body_id);
223-
let impl_item_def_id = cx.tcx.hir().local_def_id(item.hir_id);
224221
let mut fpu = FindPanicUnwrap {
225222
cx,
226-
typeck_results: cx.tcx.typeck(impl_item_def_id),
223+
typeck_results: cx.tcx.typeck(item.def_id),
227224
panic_span: None,
228225
};
229226
fpu.visit_expr(&body.value);
230-
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id), fpu.panic_span);
227+
lint_for_missing_headers(
228+
cx,
229+
item.hir_id(),
230+
item.span,
231+
sig,
232+
headers,
233+
Some(body_id),
234+
fpu.panic_span,
235+
);
231236
}
232237
},
233238
hir::ItemKind::Impl(ref impl_) => {
@@ -247,7 +252,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
247252
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
248253
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
249254
if !in_external_macro(cx.tcx.sess, item.span) {
250-
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None, None);
255+
lint_for_missing_headers(cx, item.hir_id(), item.span, sig, headers, None, None);
251256
}
252257
}
253258
}
@@ -259,14 +264,21 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
259264
}
260265
if let hir::ImplItemKind::Fn(ref sig, body_id) = item.kind {
261266
let body = cx.tcx.hir().body(body_id);
262-
let impl_item_def_id = cx.tcx.hir().local_def_id(item.hir_id);
263267
let mut fpu = FindPanicUnwrap {
264268
cx,
265-
typeck_results: cx.tcx.typeck(impl_item_def_id),
269+
typeck_results: cx.tcx.typeck(item.def_id),
266270
panic_span: None,
267271
};
268272
fpu.visit_expr(&body.value);
269-
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id), fpu.panic_span);
273+
lint_for_missing_headers(
274+
cx,
275+
item.hir_id(),
276+
item.span,
277+
sig,
278+
headers,
279+
Some(body_id),
280+
fpu.panic_span,
281+
);
270282
}
271283
}
272284
}

clippy_lints/src/empty_enum.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ impl<'tcx> LateLintPass<'tcx> for EmptyEnum {
4949
return;
5050
}
5151

52-
let did = cx.tcx.hir().local_def_id(item.hir_id);
5352
if let ItemKind::Enum(..) = item.kind {
54-
let ty = cx.tcx.type_of(did);
53+
let ty = cx.tcx.type_of(item.def_id);
5554
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
5655
if adt.variants.is_empty() {
5756
span_lint_and_help(

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/exhaustive_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl LateLintPass<'_> for ExhaustiveItems {
7272
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
7373
if_chain! {
7474
if let ItemKind::Enum(..) | ItemKind::Struct(..) = item.kind;
75-
if cx.access_levels.is_exported(item.hir_id);
75+
if cx.access_levels.is_exported(item.hir_id());
7676
if !item.attrs.iter().any(|a| a.has_name(sym::non_exhaustive));
7777
then {
7878
let (lint, msg) = if let ItemKind::Struct(ref v, ..) = item.kind {

clippy_lints/src/fallible_impl_from.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ declare_lint_pass!(FallibleImplFrom => [FALLIBLE_IMPL_FROM]);
5252
impl<'tcx> LateLintPass<'tcx> for FallibleImplFrom {
5353
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
5454
// check for `impl From<???> for ..`
55-
let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id);
5655
if_chain! {
5756
if let hir::ItemKind::Impl(impl_) = &item.kind;
58-
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
57+
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(item.def_id);
5958
if cx.tcx.is_diagnostic_item(sym::from_trait, impl_trait_ref.def_id);
6059
then {
6160
lint_impl_body(cx, item.span, impl_.items);
@@ -117,10 +116,9 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h
117116
then {
118117
// check the body for `begin_panic` or `unwrap`
119118
let body = cx.tcx.hir().body(body_id);
120-
let impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.id.hir_id);
121119
let mut fpu = FindPanicUnwrap {
122120
lcx: cx,
123-
typeck_results: cx.tcx.typeck(impl_item_def_id),
121+
typeck_results: cx.tcx.typeck(impl_item.id.def_id),
124122
result: Vec::new(),
125123
};
126124
fpu.visit_expr(&body.value);

clippy_lints/src/from_over_into.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ impl LateLintPass<'_> for FromOverInto {
6060
return;
6161
}
6262

63-
let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id);
6463
if_chain! {
6564
if let hir::ItemKind::Impl{ .. } = &item.kind;
66-
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
65+
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(item.def_id);
6766
if match_def_path(cx, impl_trait_ref.def_id, &INTO);
6867

6968
then {

clippy_lints/src/functions.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,13 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
283283
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
284284
let attr = must_use_attr(&item.attrs);
285285
if let hir::ItemKind::Fn(ref sig, ref _generics, ref body_id) = item.kind {
286-
let is_public = cx.access_levels.is_exported(item.hir_id);
286+
let is_public = cx.access_levels.is_exported(item.hir_id());
287287
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
288288
if is_public {
289289
check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
290290
}
291291
if let Some(attr) = attr {
292-
check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr);
292+
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
293293
return;
294294
}
295295
if is_public && !is_proc_macro(cx.sess(), &item.attrs) && attr_by_name(&item.attrs, "no_mangle").is_none() {
@@ -298,7 +298,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
298298
&sig.decl,
299299
cx.tcx.hir().body(*body_id),
300300
item.span,
301-
item.hir_id,
301+
item.hir_id(),
302302
item.span.with_hi(sig.decl.output.span().hi()),
303303
"this function could have a `#[must_use]` attribute",
304304
);
@@ -308,24 +308,24 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
308308

309309
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
310310
if let hir::ImplItemKind::Fn(ref sig, ref body_id) = item.kind {
311-
let is_public = cx.access_levels.is_exported(item.hir_id);
311+
let is_public = cx.access_levels.is_exported(item.hir_id());
312312
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
313-
if is_public && trait_ref_of_method(cx, item.hir_id).is_none() {
313+
if is_public && trait_ref_of_method(cx, item.hir_id()).is_none() {
314314
check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
315315
}
316316
let attr = must_use_attr(&item.attrs);
317317
if let Some(attr) = attr {
318-
check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr);
318+
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
319319
} else if is_public
320320
&& !is_proc_macro(cx.sess(), &item.attrs)
321-
&& trait_ref_of_method(cx, item.hir_id).is_none()
321+
&& trait_ref_of_method(cx, item.hir_id()).is_none()
322322
{
323323
check_must_use_candidate(
324324
cx,
325325
&sig.decl,
326326
cx.tcx.hir().body(*body_id),
327327
item.span,
328-
item.hir_id,
328+
item.hir_id(),
329329
item.span.with_hi(sig.decl.output.span().hi()),
330330
"this method could have a `#[must_use]` attribute",
331331
);
@@ -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/inherent_impl.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,15 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
5959
// but filter out implementations that have generic params (type or lifetime)
6060
// or are derived from a macro
6161
if !in_macro(item.span) && generics.params.is_empty() {
62-
self.impls.insert(item.hir_id.owner.to_def_id(), item.span);
62+
self.impls.insert(item.def_id.to_def_id(), item.span);
6363
}
6464
}
6565
}
6666

6767
fn check_crate_post(&mut self, cx: &LateContext<'tcx>, krate: &'tcx Crate<'_>) {
68-
if let Some(item) = krate.items.values().next() {
68+
if !krate.items.is_empty() {
6969
// Retrieve all inherent implementations from the crate, grouped by type
70-
for impls in cx
71-
.tcx
72-
.crate_inherent_impls(item.hir_id.owner.to_def_id().krate)
73-
.inherent_impls
74-
.values()
75-
{
70+
for impls in cx.tcx.crate_inherent_impls(def_id::LOCAL_CRATE).inherent_impls.values() {
7671
// Filter out implementations that have generic params (type or lifetime)
7772
let mut impl_spans = impls.iter().filter_map(|impl_def| self.impls.get(impl_def));
7873
if let Some(initial_span) = impl_spans.next() {

0 commit comments

Comments
 (0)