提交 32eb10f5 编写于 作者: O Oliver Schneider

Simplify the char correctness check

上级 d0b315f2
......@@ -1365,11 +1365,9 @@ fn validate_scalar(
// has no special checks for chars
match ty.sty {
ty::TyChar => {
assert_eq!(size.bytes(), 4);
let c = self.memory.read_scalar(ptr, ptr_align, Size::from_bytes(4))?.read()?.to_bits(Size::from_bytes(4))? as u32;
match ::std::char::from_u32(c) {
Some(..) => (),
None => return err!(InvalidChar(c as u128)),
debug_assert_eq!(size.bytes(), 4);
if ::std::char::from_u32(bits as u32).is_none() {
return err!(InvalidChar(bits));
}
}
_ => {},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册