-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Eternal lint on a recursive tree #13544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like a hang in the significant_drop_tightening lint. Reduced a bit further: use std::marker::PhantomData;
trait Trait {
type Assoc: Trait;
}
struct S<T: Trait>(*const S<T::Assoc>, PhantomData<T>);
fn f<T: Trait>(x: &mut S<T>) {
&mut x.0;
}
fn main() {} We keep recursing into the first field of the struct and always miss the type cache because each level of nesting adds another projection ( |
Sigh... There are many errors related to |
The below code causes trait Bar {
type Element: Bar;
}
enum Foo<T: Bar> {
A(*const Foo<T::Element>),
B(T),
} (In addition, it causes rustdoc to hang. See rust-lang/rust#139964) |
For y21's code:
Adding |
For the record, the code by The code in the OP (and my reproducer) triggers a different bug in I imagine this issue could probably be fixed in the same way as the other issue was fixed (just bail if we recurse too much in this function, which is where the stack overflow/hang happens, and conservatively return false) |
Indeed, done this way in #14641 a few minutes ago while you were writing this message, and assigned to you for review 😃 |
And the PR missed the Clippy sync by one day, which made it miss master→1.86, which is why it will be present only in 1.87. |
Limit the recursion depth, as each level of nesting adds another deeper projection. There might be a more complex way of handling the problem, but infinite recursions are bad, and don't allow Clippy to terminate properly. changelog: [`significant_drop_tightening`]: do not recurse forever when checking for attribute on type or its constituent Fixes #13544 @rustbot label +L-nursery
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: