Skip to content

Commit 1cbe927

Browse files
committed
Only avoid anon consts during instantiation
1 parent 1512d06 commit 1cbe927

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

compiler/rustc_smir/src/rustc_smir/builder.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! monomorphic body using internal representation.
55
//! After that, we convert the internal representation into a stable one.
66
use crate::rustc_smir::{Stable, Tables};
7+
use rustc_hir::def::DefKind;
78
use rustc_middle::mir;
89
use rustc_middle::mir::visit::MutVisitor;
910
use rustc_middle::ty::{self, TyCtxt};
@@ -29,10 +30,12 @@ impl<'tcx> BodyBuilder<'tcx> {
2930
/// All constants are also evaluated.
3031
pub fn build(mut self, tables: &mut Tables<'tcx>) -> stable_mir::mir::Body {
3132
let body = tables.tcx.instance_mir(self.instance.def).clone();
32-
let mono_body = if self.tcx.def_kind(self.instance.def_id()).is_fn_like()
33-
|| !self.instance.args.is_empty()
33+
let mono_body = if !self.instance.args.is_empty()
34+
// Without the `generic_const_exprs` feature gate, anon consts in signatures do not
35+
// get generic parameters. Which is wrong, but also not a problem without
36+
// generic_const_exprs
37+
|| self.tcx.def_kind(self.instance.def_id()) != DefKind::AnonConst
3438
{
35-
// This call will currently will ICE in some shims which are already monomorphic.
3639
let mut mono_body = self.instance.instantiate_mir_and_normalize_erasing_regions(
3740
tables.tcx,
3841
ty::ParamEnv::reveal_all(),

0 commit comments

Comments
 (0)