Implement char type in adapter fusion (#4544)

This commit implements the translation of `char` which validates that
it's in the valid range of unicode scalar values. The precise validation
here is lifted from LLVM in the hopes that it's probably better than
whatever I would concoct by hand.
This commit is contained in:
Alex Crichton
2022-07-28 11:47:01 -05:00
committed by GitHub
parent 8137432e67
commit e1148e43be
4 changed files with 175 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ pub enum Trap {
CannotEnter,
UnalignedPointer,
InvalidDiscriminant,
InvalidChar,
AssertFailed(&'static str),
}
@@ -101,6 +102,7 @@ impl fmt::Display for Trap {
Trap::CannotEnter => "cannot enter instance".fmt(f),
Trap::UnalignedPointer => "pointer not aligned correctly".fmt(f),
Trap::InvalidDiscriminant => "invalid variant discriminant".fmt(f),
Trap::InvalidChar => "invalid char value specified".fmt(f),
Trap::AssertFailed(s) => write!(f, "assertion failure: {}", s),
}
}