Skip to content

Commit ac0458a

Browse files
committed
stall on on constants that contain infer vars in const_eval_resolve
1 parent 47f78a2 commit ac0458a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

compiler/rustc_middle/src/mir/interpret/queries.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::{ErrorHandled, EvalToConstValueResult, GlobalId};
22

33
use crate::mir;
4+
use crate::ty::fold::TypeFoldable;
45
use crate::ty::subst::InternalSubsts;
56
use crate::ty::{self, TyCtxt};
67
use rustc_hir::def_id::DefId;
@@ -38,6 +39,13 @@ impl<'tcx> TyCtxt<'tcx> {
3839
ct: ty::Unevaluated<'tcx>,
3940
span: Option<Span>,
4041
) -> EvalToConstValueResult<'tcx> {
42+
// Cannot resolve `Unevaluated` constants that contain inference
43+
// variables. We reject those here since `resolve_opt_const_arg`
44+
// would fail otherwise
45+
if ct.substs.has_infer_types_or_consts() {
46+
return Err(ErrorHandled::TooGeneric);
47+
}
48+
4149
match ty::Instance::resolve_opt_const_arg(self, param_env, ct.def, ct.substs) {
4250
Ok(Some(instance)) => {
4351
let cid = GlobalId { instance, promoted: ct.promoted };

0 commit comments

Comments
 (0)