about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-04-16 09:11:18 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-06-12 09:57:06 +0000
commitde4e7adc966e0e1a6aaff455fbeaf979b80f461c (patch)
treec104ffa359c37ce7d472a8bb77ce1dbe1ce0d30a
parentfe5c95d4ae33ec9d7831921e448e2daf8264ea42 (diff)
downloadrust-de4e7adc966e0e1a6aaff455fbeaf979b80f461c.tar.gz
rust-de4e7adc966e0e1a6aaff455fbeaf979b80f461c.zip
Don't hardcode the intrinsic return types twice in the compiler
-rw-r--r--compiler/rustc_const_eval/src/interpret/intrinsics.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
index ab27182c211..c9a2d61daaa 100644
--- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs
+++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
@@ -139,13 +139,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
 
             sym::needs_drop | sym::type_id | sym::type_name | sym::variant_count => {
                 let gid = GlobalId { instance, promoted: None };
-                let ty = match intrinsic_name {
-                    sym::variant_count => self.tcx.types.usize,
-                    sym::needs_drop => self.tcx.types.bool,
-                    sym::type_id => self.tcx.types.u128,
-                    sym::type_name => Ty::new_static_str(self.tcx.tcx),
-                    _ => bug!(),
-                };
+                let ty = self
+                    .tcx
+                    .fn_sig(instance.def_id())
+                    .instantiate(self.tcx.tcx, instance.args)
+                    .output()
+                    .no_bound_vars()
+                    .unwrap();
                 let val = self
                     .ctfe_query(|tcx| tcx.const_eval_global_id(self.typing_env, gid, tcx.span))?;
                 let val = self.const_val_to_op(val, ty, Some(dest.layout))?;