Closed
Description
Summary
This code causes clippy to hang & never complete linting.
use std::mem::ManuallyDrop;
use std::ops::Deref;
use std::ops::DerefMut;
trait Scopable: Sized {
type SubType: Scopable;
}
struct Subtree<T: Scopable>(ManuallyDrop<Box<Tree<T::SubType>>>);
impl<T: Scopable> Drop for Subtree<T> {
fn drop(&mut self) {
// SAFETY: The field cannot be used after we drop
unsafe { ManuallyDrop::drop(&mut self.0) }
}
}
impl<T: Scopable> Deref for Subtree<T> {
type Target = Tree<T::SubType>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<T: Scopable> DerefMut for Subtree<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
enum Tree<T: Scopable> {
Group(Vec<Tree<T>>),
Subtree(Subtree<T>),
Leaf(T),
}
impl<T: Scopable> Tree<T> {
fn foo(self) -> Self {
self
}
}
fn main() {}
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