Skip to content

Commit b6f7eef

Browse files
author
Tunahan Karlibas
committed
Remove unnecessary check and fix local_def_id parameter
1 parent de1cd4b commit b6f7eef

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

compiler/rustc_mir/src/const_eval/eval_queries.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::interpret::{
77
};
88

99
use rustc_errors::ErrorReported;
10-
use rustc_hir::def::DefKind;
10+
use rustc_hir::{ConstContext, def::DefKind};
1111
use rustc_middle::mir;
1212
use rustc_middle::mir::interpret::ErrorHandled;
1313
use rustc_middle::traits::Reveal;
@@ -30,14 +30,14 @@ fn eval_body_using_ecx<'mir, 'tcx>(
3030
body: &'mir mir::Body<'tcx>,
3131
) -> InterpResult<'tcx, MPlaceTy<'tcx>> {
3232
debug!("eval_body_using_ecx: {:?}, {:?}", cid, ecx.param_env);
33+
let tcx = *ecx.tcx;
3334
assert!(
3435
cid.promoted.is_some()
3536
|| matches!(
36-
ecx.tcx.hir().body_const_context(def_id),
37+
ecx.tcx.hir().body_const_context(cid.instance.def_id().expect_local()),
3738
Some(ConstContext::Const | ConstContext::Static(_))
3839
)
3940
);
40-
let tcx = *ecx.tcx;
4141
let layout = ecx.layout_of(body.return_ty().subst(tcx, cid.instance.substs))?;
4242
assert!(!layout.is_unsized());
4343
let ret = ecx.allocate(layout, MemoryKind::Stack);
@@ -47,14 +47,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
4747
let prom = cid.promoted.map_or(String::new(), |p| format!("::promoted[{:?}]", p));
4848
trace!("eval_body_using_ecx: pushing stack frame for global: {}{}", name, prom);
4949

50-
// Assert all args (if any) are zero-sized types; `eval_body_using_ecx` doesn't
51-
// make sense if the body is expecting nontrivial arguments.
52-
// (The alternative would be to use `eval_fn_call` with an args slice.)
53-
for arg in body.args_iter() {
54-
let decl = body.local_decls.get(arg).expect("arg missing from local_decls");
55-
let layout = ecx.layout_of(decl.ty.subst(tcx, cid.instance.substs))?;
56-
assert!(layout.is_zst())
57-
}
50+
5851

5952
ecx.push_stack_frame(
6053
cid.instance,

0 commit comments

Comments
 (0)