Simplify the char correctness check
This commit is contained in:
parent
d0b315f262
commit
32eb10f54d
1 changed files with 3 additions and 5 deletions
|
@ -1365,11 +1365,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
|
||||||
// has no special checks for chars
|
// has no special checks for chars
|
||||||
match ty.sty {
|
match ty.sty {
|
||||||
ty::TyChar => {
|
ty::TyChar => {
|
||||||
assert_eq!(size.bytes(), 4);
|
debug_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;
|
if ::std::char::from_u32(bits as u32).is_none() {
|
||||||
match ::std::char::from_u32(c) {
|
return err!(InvalidChar(bits));
|
||||||
Some(..) => (),
|
|
||||||
None => return err!(InvalidChar(c as u128)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {},
|
_ => {},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue