Closed
Description
The following code will cause rust analyzer to become unresponsive, exhausting all (?) available CPU and memory resources:
use std::marker::PhantomData;
struct TypeWrapper<'a> {
inner: InnerType,
_ref: PhantomData<&'a mut BorrowWrapper<'a>>,
}
struct BorrowWrapper<'a> {
inner: &'a mut InnerType,
}
struct InnerType;
pub trait GetBorrow {
type TypeA;
type TypeB;
fn get_type_a(&mut self) -> Self::TypeA;
fn get_type_b(&mut self) -> Self::TypeB;
}
impl<'a> GetBorrow for TypeWrapper<'a>
where
Self::TypeA: 'a,
Self::TypeB: 'a,
{
type TypeA = BorrowWrapper<'a>;
type TypeB = BorrowWrapper<'a>;
fn get_type_a(&mut self) -> Self::TypeA {
BorrowWrapper {
inner: &mut self.inner,
}
}
fn get_type_b(&mut self) -> Self::TypeB {
BorrowWrapper {
inner: &mut self.inner,
}
}
}
Updating, and switching between nightly
and stable
do not solve the issue.
rustc --version --verbose
gives the following:
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-unknown-linux-gnu
release: 1.79.0
LLVM version: 18.1.7
rust-analyzer --version
gives the following:
rust-analyzer 1 (c4618fe14 2024-05-05)