From 1cbe92716f0f0f9f15ff890773fad5ffcf534311 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 10 Apr 2024 04:49:27 +0000 Subject: [PATCH] Only avoid anon consts during instantiation --- compiler/rustc_smir/src/rustc_smir/builder.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/builder.rs b/compiler/rustc_smir/src/rustc_smir/builder.rs index f32788bb829..221224eed01 100644 --- a/compiler/rustc_smir/src/rustc_smir/builder.rs +++ b/compiler/rustc_smir/src/rustc_smir/builder.rs @@ -4,6 +4,7 @@ //! monomorphic body using internal representation. //! After that, we convert the internal representation into a stable one. use crate::rustc_smir::{Stable, Tables}; +use rustc_hir::def::DefKind; use rustc_middle::mir; use rustc_middle::mir::visit::MutVisitor; use rustc_middle::ty::{self, TyCtxt}; @@ -29,10 +30,12 @@ impl<'tcx> BodyBuilder<'tcx> { /// All constants are also evaluated. pub fn build(mut self, tables: &mut Tables<'tcx>) -> stable_mir::mir::Body { let body = tables.tcx.instance_mir(self.instance.def).clone(); - let mono_body = if self.tcx.def_kind(self.instance.def_id()).is_fn_like() - || !self.instance.args.is_empty() + let mono_body = if !self.instance.args.is_empty() + // Without the `generic_const_exprs` feature gate, anon consts in signatures do not + // get generic parameters. Which is wrong, but also not a problem without + // generic_const_exprs + || self.tcx.def_kind(self.instance.def_id()) != DefKind::AnonConst { - // This call will currently will ICE in some shims which are already monomorphic. let mut mono_body = self.instance.instantiate_mir_and_normalize_erasing_regions( tables.tcx, ty::ParamEnv::reveal_all(),