Skip to content

Commit 8904bdd

Browse files
committed
Determine type of intrinsics instead of assuming the destination type is the same.
1 parent 774a029 commit 8904bdd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustc_mir/interpret/intrinsics.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
110110
| sym::type_id
111111
| sym::type_name => {
112112
let gid = GlobalId { instance, promoted: None };
113-
let val = self.const_eval(gid, dest.layout.ty)?;
113+
let ty = match intrinsic_name {
114+
sym::min_align_of | sym::pref_align_of | sym::size_of => self.tcx.types.usize,
115+
sym::needs_drop => self.tcx.types.bool,
116+
sym::type_id => self.tcx.types.u64,
117+
sym::type_name => self.tcx.mk_static_str(),
118+
_ => span_bug!(span, "Already checked for nullary intrinsics"),
119+
};
120+
let val = self.const_eval(gid, ty)?;
114121
self.copy_op(val, dest)?;
115122
}
116123

0 commit comments

Comments
 (0)