Skip to content

Commit 928ca72

Browse files
committed
Auto merge of #5520 - matthiaskrgr:rustup_44, r=flip1995
rustup rust-lang/rust#71215 There's currently an crash in `ui/new_without_default.rs` that I need to figure out how to avoid. changelog: none
2 parents 02c9435 + f9c1acb commit 928ca72

11 files changed

+27
-22
lines changed

clippy_lints/src/cognitive_complexity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CognitiveComplexity {
123123
hir_id: HirId,
124124
) {
125125
let def_id = cx.tcx.hir().local_def_id(hir_id);
126-
if !cx.tcx.has_attr(def_id, sym!(test)) {
126+
if !cx.tcx.has_attr(def_id.to_def_id(), sym!(test)) {
127127
self.check(cx, kind, decl, body, span);
128128
}
129129
}

clippy_lints/src/derive.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,20 @@ fn check_hash_peq<'a, 'tcx>(
160160
};
161161

162162
span_lint_and_then(
163-
cx, DERIVE_HASH_XOR_EQ, span,
163+
cx,
164+
DERIVE_HASH_XOR_EQ,
165+
span,
164166
mess,
165167
|diag| {
166-
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(impl_id) {
167-
diag.span_note(
168-
cx.tcx.hir().span(hir_id),
169-
"`PartialEq` implemented here"
170-
);
168+
if let Some(local_def_id) = impl_id.as_local() {
169+
let hir_id = cx.tcx.hir().as_local_hir_id(local_def_id);
170+
diag.span_note(
171+
cx.tcx.hir().span(hir_id),
172+
"`PartialEq` implemented here"
173+
);
174+
}
171175
}
172-
});
176+
);
173177
}
174178
});
175179
}
@@ -225,7 +229,7 @@ fn check_unsafe_derive_deserialize<'a, 'tcx>(
225229
ty: Ty<'tcx>,
226230
) {
227231
fn item_from_def_id<'tcx>(cx: &LateContext<'_, 'tcx>, def_id: DefId) -> &'tcx Item<'tcx> {
228-
let hir_id = cx.tcx.hir().as_local_hir_id(def_id).unwrap();
232+
let hir_id = cx.tcx.hir().as_local_hir_id(def_id.expect_local());
229233
cx.tcx.hir().expect_item(hir_id)
230234
}
231235

clippy_lints/src/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
155155
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
156156
match item.kind {
157157
hir::ItemKind::Fn(ref sig, _, body_id) => {
158-
if !(is_entrypoint_fn(cx, cx.tcx.hir().local_def_id(item.hir_id))
158+
if !(is_entrypoint_fn(cx, cx.tcx.hir().local_def_id(item.hir_id).to_def_id())
159159
|| in_external_macro(cx.tcx.sess, item.span))
160160
{
161161
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id));

clippy_lints/src/escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
7777

7878
let fn_def_id = cx.tcx.hir().local_def_id(hir_id);
7979
cx.tcx.infer_ctxt().enter(|infcx| {
80-
ExprUseVisitor::new(&mut v, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
80+
ExprUseVisitor::new(&mut v, &infcx, fn_def_id.to_def_id(), cx.param_env, cx.tables).consume_body(body);
8181
});
8282

8383
for node in v.set {

clippy_lints/src/exit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Exit {
3737
// If the next item up is a function we check if it is an entry point
3838
// and only then emit a linter warning
3939
let def_id = cx.tcx.hir().local_def_id(parent);
40-
if !is_entrypoint_fn(cx, def_id) {
40+
if !is_entrypoint_fn(cx, def_id.to_def_id()) {
4141
span_lint(cx, EXIT, e.span, "usage of `process::exit`");
4242
}
4343
}

clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item<'_>, trait_i
143143
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
144144
let mut current_and_super_traits = FxHashSet::default();
145145
let visited_trait_def_id = cx.tcx.hir().local_def_id(visited_trait.hir_id);
146-
fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);
146+
fill_trait_set(visited_trait_def_id.to_def_id(), &mut current_and_super_traits, cx);
147147

148148
let is_empty_method_found = current_and_super_traits
149149
.iter()

clippy_lints/src/missing_const_for_fn.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingConstForFn {
8383
) {
8484
let def_id = cx.tcx.hir().local_def_id(hir_id);
8585

86-
if in_external_macro(cx.tcx.sess, span) || is_entrypoint_fn(cx, def_id) {
86+
if in_external_macro(cx.tcx.sess, span) || is_entrypoint_fn(cx, def_id.to_def_id()) {
8787
return;
8888
}
8989

9090
// Building MIR for `fn`s with unsatisfiable preds results in ICE.
91-
if fn_has_unsatisfiable_preds(cx, def_id) {
91+
if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) {
9292
return;
9393
}
9494

@@ -118,8 +118,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingConstForFn {
118118

119119
let mir = cx.tcx.optimized_mir(def_id);
120120

121-
if let Err((span, err)) = is_min_const_fn(cx.tcx, def_id, &mir) {
122-
if rustc_mir::const_eval::is_min_const_fn(cx.tcx, def_id) {
121+
if let Err((span, err)) = is_min_const_fn(cx.tcx, def_id.to_def_id(), &mir) {
122+
if rustc_mir::const_eval::is_min_const_fn(cx.tcx, def_id.to_def_id()) {
123123
cx.tcx.sess.span_err(span, &err);
124124
}
125125
} else {

clippy_lints/src/missing_inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
152152
};
153153

154154
if let Some(trait_def_id) = trait_def_id {
155-
if cx.tcx.hir().as_local_hir_id(trait_def_id).is_some() && !cx.access_levels.is_exported(impl_item.hir_id) {
155+
if trait_def_id.is_local() && !cx.access_levels.is_exported(impl_item.hir_id) {
156156
// If a trait is being implemented for an item, and the
157157
// trait is not exported, we don't need #[inline]
158158
return;

clippy_lints/src/needless_pass_by_value.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
135135
} = {
136136
let mut ctx = MovedVariablesCtxt::default();
137137
cx.tcx.infer_ctxt().enter(|infcx| {
138-
euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id, cx.param_env, cx.tables).consume_body(body);
138+
euv::ExprUseVisitor::new(&mut ctx, &infcx, fn_def_id.to_def_id(), cx.param_env, cx.tables)
139+
.consume_body(body);
139140
});
140141
ctx
141142
};

clippy_lints/src/new_without_default.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
136136
let mut impls = HirIdSet::default();
137137
cx.tcx.for_each_impl(default_trait_id, |d| {
138138
if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() {
139-
if let Some(hir_id) = cx.tcx.hir().as_local_hir_id(ty_def.did) {
140-
impls.insert(hir_id);
139+
if let Some(local_def_id) = ty_def.did.as_local() {
140+
impls.insert(cx.tcx.hir().as_local_hir_id(local_def_id));
141141
}
142142
}
143143
});

clippy_lints/src/utils/inspector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
378378
},
379379
hir::ItemKind::Trait(..) => {
380380
println!("trait decl");
381-
if cx.tcx.trait_is_auto(did) {
381+
if cx.tcx.trait_is_auto(did.to_def_id()) {
382382
println!("trait is auto");
383383
} else {
384384
println!("trait is not auto");

0 commit comments

Comments
 (0)