Skip to content

significant_drop_tightening is very slow #10532

@Noratrieb

Description

@Noratrieb

Description

significant_drop_tightening is very slow. I tried running clippy with -Aclippy::all -Wclippy::perf on rustc_borrowck. (note that it seemed very slow on the entire compiler, so I don't think there's anything specific to borrowck, it's just very big.

According to a profile, it spends about 66% of time inside has_sig_drop_attr:

pub(crate) fn has_sig_drop_attr(&mut self, ty: Ty<'tcx>) -> bool {

More precisely, it seems to spend the time getting the type of fields.

let ty = f.ty(self.cx.tcx, b);

Inside this function it substitutes the type of the field with the substs (generic parameters) of the type. This folds the type and is a little work. This lint does that little work on everything, turning it into a lot of work. It also does so eagerly recursively which is just a receipe for slowness.

I've got a simple fix, I'll send in a PR.

Version

current master, e64c5961dc7640b4d5529608e0f321d586c027a0, 1.70.0

Additional Labels

@rustbot label +C-bug

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions