You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code causes clippy to hang & never complete linting.
use std::mem::ManuallyDrop;use std::ops::Deref;use std::ops::DerefMut;traitScopable:Sized{typeSubType:Scopable;}structSubtree<T:Scopable>(ManuallyDrop<Box<Tree<T::SubType>>>);impl<T:Scopable>DropforSubtree<T>{fndrop(&mutself){// SAFETY: The field cannot be used after we dropunsafe{ManuallyDrop::drop(&mutself.0)}}}impl<T:Scopable>DerefforSubtree<T>{typeTarget = Tree<T::SubType>;fnderef(&self) -> &Self::Target{&self.0}}impl<T:Scopable>DerefMutforSubtree<T>{fnderef_mut(&mutself) -> &mutSelf::Target{&mutself.0}}enumTree<T:Scopable>{Group(Vec<Tree<T>>),Subtree(Subtree<T>),Leaf(T),}impl<T:Scopable>Tree<T>{fnfoo(self) -> Self{self}}fnmain(){}
Reproducer
I tried this code:(See above)
I expected to see this happen: Clippy finish linting within a reasonable time period
Instead, this happened: Clippy doesn't finish linting & hangs, eating 90% cpu
Looks like a hang in the significant_drop_tightening lint. Reduced a bit further:
use std::marker::PhantomData;traitTrait{typeAssoc:Trait;}structS<T:Trait>(*constS<T::Assoc>,PhantomData<T>);fnf<T:Trait>(x:&mutS<T>){&mut x.0;}fnmain(){}
We keep recursing into the first field of the struct and always miss the type cache because each level of nesting adds another projection (S<T::Assoc> -> S<T::Assoc::Assoc> -> S<T::Assoc::Assoc::Assoc> ...).
Summary
This code causes clippy to hang & never complete linting.
Reproducer
I tried this code:(See above)
I expected to see this happen: Clippy finish linting within a reasonable time period
Instead, this happened: Clippy doesn't finish linting & hangs, eating 90% cpu
Version
rustc 1.83.0-nightly (1bc403daa 2024-10-11)
binary: rustc
commit-hash: 1bc403daadbebb553ccc211a0a8eebb73989665f
commit-date: 2024-10-11
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.1
Additional Labels
No response
The text was updated successfully, but these errors were encountered: