Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/mir/eval/shim.rs')
| -rw-r--r-- | crates/hir-ty/src/mir/eval/shim.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/crates/hir-ty/src/mir/eval/shim.rs b/crates/hir-ty/src/mir/eval/shim.rs index 9db6b36588..e569b32bd7 100644 --- a/crates/hir-ty/src/mir/eval/shim.rs +++ b/crates/hir-ty/src/mir/eval/shim.rs @@ -733,9 +733,7 @@ impl<'a, 'db> Evaluator<'a, 'db> { let size = self.size_of_sized(ty, locals, "size_of arg")?; destination.write_from_bytes(self, &size.to_le_bytes()[0..destination.size]) } - // FIXME: `min_align_of` was renamed to `align_of` in Rust 1.89 - // (https://github.com/rust-lang/rust/pull/142410) - "min_align_of" | "align_of" => { + "align_of" => { let Some(ty) = generic_args.as_slice().first().and_then(|it| it.ty()) else { return Err(MirEvalError::InternalError( "align_of generic arg is not provided".into(), @@ -763,9 +761,7 @@ impl<'a, 'db> Evaluator<'a, 'db> { destination.write_from_bytes(self, &size.to_le_bytes()) } } - // FIXME: `min_align_of_val` was renamed to `align_of_val` in Rust 1.89 - // (https://github.com/rust-lang/rust/pull/142410) - "min_align_of_val" | "align_of_val" => { + "align_of_val" => { let Some(ty) = generic_args.as_slice().first().and_then(|it| it.ty()) else { return Err(MirEvalError::InternalError( "align_of_val generic arg is not provided".into(), @@ -1415,6 +1411,15 @@ impl<'a, 'db> Evaluator<'a, 'db> { self.write_memory(location_addr, &location)?; destination.write_from_bytes(self, &location_addr.to_bytes()[..ptr_size]) } + "box_new" => { + let ty = generic_args.type_at(0); + let Some((size, align)) = self.size_align_of(ty, locals)? else { + not_supported!("unsized box initialization"); + }; + let addr = self.heap_allocate(size, align)?; + self.copy_from_interval(addr, args[0].interval)?; + destination.write_from_bytes(self, &addr.to_bytes()[..self.ptr_size()]) + } _ if needs_override => not_supported!("intrinsic {name} is not implemented"), _ => return Ok(false), } |