Skip to content

Commit

Permalink
Determine type of intrinsics instead of assuming the destination type…
Browse files Browse the repository at this point in the history
… is the same.
  • Loading branch information
skinnyBat committed Feb 15, 2020
1 parent 774a029 commit 8904bdd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/librustc_mir/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
| sym::type_id
| sym::type_name => {
let gid = GlobalId { instance, promoted: None };
let val = self.const_eval(gid, dest.layout.ty)?;
let ty = match intrinsic_name {
sym::min_align_of | sym::pref_align_of | sym::size_of => self.tcx.types.usize,
sym::needs_drop => self.tcx.types.bool,
sym::type_id => self.tcx.types.u64,
sym::type_name => self.tcx.mk_static_str(),
_ => span_bug!(span, "Already checked for nullary intrinsics"),
};
let val = self.const_eval(gid, ty)?;
self.copy_op(val, dest)?;
}

Expand Down

0 comments on commit 8904bdd

Please sign in to comment.