Implement align_offset intrinsic and thus enabling from_utf8

This commit is contained in:
Oliver Schneider 2017-09-01 12:26:51 +02:00
parent 3243843755
commit cf25ef9d9d
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9
2 changed files with 9 additions and 0 deletions

View file

@ -34,6 +34,12 @@ impl<'a, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'tcx, super::Evaluator>
let intrinsic_name = &self.tcx.item_name(instance.def_id()).as_str()[..];
match intrinsic_name {
"align_offset" => {
// FIXME: return a real value in case the target allocation has an
// alignment bigger than the one requested
self.write_primval(dest, PrimVal::Bytes(u128::max_value()), dest_ty)?;
},
"add_with_overflow" => {
self.intrinsic_with_overflow(
mir::BinOp::Add,

View file

@ -0,0 +1,3 @@
fn main() {
let _ = ::std::str::from_utf8(b"a");
}