Skip to content

Commit 789e828

Browse files
Don't call with_reveal_all_normalized in evaluate when param-env has inference vars in it
1 parent bbf3383 commit 789e828

File tree

1 file changed

+4
-6
lines changed
  • compiler/rustc_middle/src/ty/consts

1 file changed

+4
-6
lines changed

compiler/rustc_middle/src/ty/consts/kind.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,21 @@ impl<'tcx> ConstKind<'tcx> {
217217
// Note that we erase regions *before* calling `with_reveal_all_normalized`,
218218
// so that we don't try to invoke this query with
219219
// any region variables.
220-
let param_env_and = tcx
221-
.erase_regions(param_env)
222-
.with_reveal_all_normalized(tcx)
223-
.and(tcx.erase_regions(unevaluated));
224220

225221
// HACK(eddyb) when the query key would contain inference variables,
226222
// attempt using identity substs and `ParamEnv` instead, that will succeed
227223
// when the expression doesn't depend on any parameters.
228224
// FIXME(eddyb, skinny121) pass `InferCtxt` into here when it's available, so that
229225
// we can call `infcx.const_eval_resolve` which handles inference variables.
230-
let param_env_and = if param_env_and.needs_infer() {
226+
let param_env_and = if (param_env, unevaluated).has_non_region_infer() {
231227
tcx.param_env(unevaluated.def.did).and(ty::UnevaluatedConst {
232228
def: unevaluated.def,
233229
substs: InternalSubsts::identity_for_item(tcx, unevaluated.def.did),
234230
})
235231
} else {
236-
param_env_and
232+
tcx.erase_regions(param_env)
233+
.with_reveal_all_normalized(tcx)
234+
.and(tcx.erase_regions(unevaluated))
237235
};
238236

239237
// FIXME(eddyb) maybe the `const_eval_*` methods should take

0 commit comments

Comments
 (0)