Skip to content

Commit 2e181e7

Browse files
committed
Auto merge of rust-lang#139018 - oli-obk:incremental-trait-impls, r=compiler-errors
Various local trait item iteration cleanups Adding a trait impl for `Foo` unconditionally affected all queries that are interested in a completely independent trait `Bar`. Perf has no effect on this. We probably don't have a good perf test for this tho. r? `@compiler-errors` I am unsure about rust-lang@9d05efb as it doesn't improve anything wrt incremental, because we still do all the checks for valid `Drop` impls, which subsequently will still invoke many queries and basically keep the depgraph the same. I want to do https://github.com/rust-lang/rust/blob/9549077a47099dc826039c051b528d1013740e6f/compiler/rustc_middle/src/ty/trait_def.rs#L141 but would leave that to a follow-up PR, this one changes enough things as it is
2 parents 4304fa2 + 777c7cd commit 2e181e7

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

clippy_lints/src/derive.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,9 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
324324
// there's a Copy impl for any instance of the adt.
325325
if !is_copy(cx, ty) {
326326
if ty_subs.non_erasable_generics().next().is_some() {
327-
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).is_some_and(|impls| {
328-
impls.iter().any(|&id| {
329-
matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _)
327+
let has_copy_impl = cx.tcx.local_trait_impls(copy_id).iter().any(|&id| {
328+
matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _)
330329
if ty_adt.did() == adt.did())
331-
})
332330
});
333331
if !has_copy_impl {
334332
return;

clippy_lints/src/new_without_default.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
9797
{
9898
if self.impling_types.is_none() {
9999
let mut impls = HirIdSet::default();
100-
cx.tcx.for_each_impl(default_trait_id, |d| {
100+
for &d in cx.tcx.local_trait_impls(default_trait_id) {
101101
let ty = cx.tcx.type_of(d).instantiate_identity();
102102
if let Some(ty_def) = ty.ty_adt_def() {
103103
if let Some(local_def_id) = ty_def.did().as_local() {
104104
impls.insert(cx.tcx.local_def_id_to_hir_id(local_def_id));
105105
}
106106
}
107-
});
107+
}
108108
self.impling_types = Some(impls);
109109
}
110110

0 commit comments

Comments
 (0)