mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Fix overflow checking in shift operator
This commit is contained in:
parent
bb85a980e0
commit
15a0da6f30
2 changed files with 7 additions and 1 deletions
|
@ -1037,13 +1037,18 @@ impl Evaluator<'_> {
|
|||
BinOp::Shr => l128.checked_shr(shift_amount),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
if shift_amount as usize >= lc.len() * 8 {
|
||||
return Err(MirEvalError::Panic(format!(
|
||||
"Overflow in {op:?}"
|
||||
)));
|
||||
}
|
||||
if let Some(r) = r {
|
||||
break 'b r;
|
||||
}
|
||||
};
|
||||
return Err(MirEvalError::Panic(format!("Overflow in {op:?}")));
|
||||
};
|
||||
check_overflow(r)?
|
||||
Owned(r.to_le_bytes()[..lc.len()].to_vec())
|
||||
}
|
||||
BinOp::Offset => not_supported!("offset binop"),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue