Skip to content

Commit 928e72d

Browse files
committed
Auto merge of rust-lang#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

+1-1
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

+1-1
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

+22-10
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

+1-2
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

+2-2
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

+1-1
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

+2-4
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

+1-2
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

+12-12
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

+3-8
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() {

clippy_lints/src/inherent_to_string.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
109109
if impl_item.generics.params.is_empty();
110110

111111
// Check if return type is String
112-
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id), sym::string_type);
112+
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::string_type);
113113

114114
// Filters instances of to_string which are required by a trait
115-
if trait_ref_of_method(cx, impl_item.hir_id).is_none();
115+
if trait_ref_of_method(cx, impl_item.hir_id()).is_none();
116116

117117
then {
118118
show_lint(cx, impl_item);
@@ -125,8 +125,7 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) {
125125
let display_trait_id = get_trait_def_id(cx, &paths::DISPLAY_TRAIT).expect("Failed to get trait ID of `Display`!");
126126

127127
// Get the real type of 'self'
128-
let fn_def_id = cx.tcx.hir().local_def_id(item.hir_id);
129-
let self_type = cx.tcx.fn_sig(fn_def_id).input(0);
128+
let self_type = cx.tcx.fn_sig(item.def_id).input(0);
130129
let self_type = self_type.skip_binder().peel_refs();
131130

132131
// Emit either a warning or an error

clippy_lints/src/large_enum_variant.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant {
6262
if in_external_macro(cx.tcx.sess, item.span) {
6363
return;
6464
}
65-
let did = cx.tcx.hir().local_def_id(item.hir_id);
6665
if let ItemKind::Enum(ref def, _) = item.kind {
67-
let ty = cx.tcx.type_of(did);
66+
let ty = cx.tcx.type_of(item.def_id);
6867
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
6968

7069
let mut largest_variant: Option<(_, _)> = None;

clippy_lints/src/len_zero.rs

+7-15
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
}
@@ -177,10 +174,9 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
177174
}
178175
}
179176

180-
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
177+
if cx.access_levels.is_exported(visited_trait.hir_id()) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
181178
let mut current_and_super_traits = FxHashSet::default();
182-
let visited_trait_def_id = cx.tcx.hir().local_def_id(visited_trait.hir_id);
183-
fill_trait_set(visited_trait_def_id.to_def_id(), &mut current_and_super_traits, cx);
179+
fill_trait_set(visited_trait.def_id.to_def_id(), &mut current_and_super_traits, cx);
184180

185181
let is_empty_method_found = current_and_super_traits
186182
.iter()
@@ -210,17 +206,14 @@ fn check_impl_items(cx: &LateContext<'_>, item: &Item<'_>, impl_items: &[ImplIte
210206
fn is_named_self(cx: &LateContext<'_>, item: &ImplItemRef<'_>, name: &str) -> bool {
211207
item.ident.name.as_str() == name
212208
&& if let AssocItemKind::Fn { has_self } = item.kind {
213-
has_self && {
214-
let did = cx.tcx.hir().local_def_id(item.id.hir_id);
215-
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
216-
}
209+
has_self && cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1
217210
} else {
218211
false
219212
}
220213
}
221214

222215
let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(cx, i, "is_empty")) {
223-
if cx.access_levels.is_exported(is_empty.id.hir_id) {
216+
if cx.access_levels.is_exported(is_empty.id.hir_id()) {
224217
return;
225218
}
226219
"a private"
@@ -229,9 +222,8 @@ fn check_impl_items(cx: &LateContext<'_>, item: &Item<'_>, impl_items: &[ImplIte
229222
};
230223

231224
if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
232-
if cx.access_levels.is_exported(i.id.hir_id) {
233-
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
234-
let ty = cx.tcx.type_of(def_id);
225+
if cx.access_levels.is_exported(i.id.hir_id()) {
226+
let ty = cx.tcx.type_of(item.def_id);
235227

236228
span_lint(
237229
cx,

clippy_lints/src/lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for Lifetimes {
8787

8888
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
8989
if let ImplItemKind::Fn(ref sig, id) = item.kind {
90-
let report_extra_lifetimes = trait_ref_of_method(cx, item.hir_id).is_none();
90+
let report_extra_lifetimes = trait_ref_of_method(cx, item.hir_id()).is_none();
9191
check_fn_inner(
9292
cx,
9393
&sig.decl,
@@ -375,7 +375,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
375375
match ty.kind {
376376
TyKind::OpaqueDef(item, _) => {
377377
let map = self.cx.tcx.hir();
378-
let item = map.expect_item(item.id);
378+
let item = map.item(item);
379379
walk_item(self, item);
380380
walk_ty(self, ty);
381381
},

clippy_lints/src/loops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ declare_clippy_lint! {
340340
/// ```
341341
pub WHILE_LET_ON_ITERATOR,
342342
style,
343-
"using a while-let loop instead of a for loop on an iterator"
343+
"using a `while let` loop instead of a for loop on an iterator"
344344
}
345345

346346
declare_clippy_lint! {

clippy_lints/src/manual_async_fn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn future_trait_ref<'tcx>(
102102
) -> Option<(&'tcx TraitRef<'tcx>, Vec<LifetimeName>)> {
103103
if_chain! {
104104
if let TyKind::OpaqueDef(item_id, bounds) = ty.kind;
105-
let item = cx.tcx.hir().item(item_id.id);
105+
let item = cx.tcx.hir().item(item_id);
106106
if let ItemKind::OpaqueTy(opaque) = &item.kind;
107107
if let Some(trait_ref) = opaque.bounds.iter().find_map(|bound| {
108108
if let GenericBound::Trait(poly, _) = bound {

0 commit comments

Comments
 (0)