Skip to content

Commit d2e080d

Browse files
committed
Don't hardcode the intrinsic return types twice in the compiler
1 parent 1c04750 commit d2e080d

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
139139

140140
sym::needs_drop | sym::type_id | sym::type_name | sym::variant_count => {
141141
let gid = GlobalId { instance, promoted: None };
142-
let ty = match intrinsic_name {
143-
sym::variant_count => self.tcx.types.usize,
144-
sym::needs_drop => self.tcx.types.bool,
145-
sym::type_id => self.tcx.types.u128,
146-
sym::type_name => Ty::new_static_str(self.tcx.tcx),
147-
_ => bug!(),
148-
};
142+
let ty = instance.ty(self.tcx.tcx, self.typing_env);
149143
let val = self
150144
.ctfe_query(|tcx| tcx.const_eval_global_id(self.typing_env, gid, tcx.span))?;
151145
let val = self.const_val_to_op(val, ty, Some(dest.layout))?;

0 commit comments

Comments
 (0)