Fix overloaded deref unused mut false positive

This commit is contained in:
hkalbasi 2023-03-02 13:52:12 +03:30
parent 6377d50bd1
commit bf0f99f15d
3 changed files with 45 additions and 6 deletions

View file

@ -263,12 +263,14 @@ impl Evaluator<'_> {
for proj in &p.projection {
match proj {
ProjectionElem::Deref => {
match &ty.data(Interner).kind {
TyKind::Ref(_, _, inner) => {
ty = inner.clone();
ty = match &ty.data(Interner).kind {
TyKind::Raw(_, inner) | TyKind::Ref(_, _, inner) => inner.clone(),
_ => {
return Err(MirEvalError::TypeError(
"Overloaded deref in MIR is disallowed",
))
}
_ => not_supported!("dereferencing smart pointers"),
}
};
let x = from_bytes!(usize, self.read_memory(addr, self.ptr_size())?);
addr = Address::from_usize(x);
}