Skip to content

Commit

Permalink
add missing constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
Tunahan Karlibas committed Dec 11, 2020
1 parent b6f7eef commit a03feaa
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions compiler/rustc_mir/src/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::interpret::{
};

use rustc_errors::ErrorReported;
use rustc_hir::{ConstContext, def::DefKind};
use rustc_hir::def::DefKind;
use rustc_middle::mir;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::traits::Reveal;
Expand All @@ -34,9 +34,15 @@ fn eval_body_using_ecx<'mir, 'tcx>(
assert!(
cid.promoted.is_some()
|| matches!(
ecx.tcx.hir().body_const_context(cid.instance.def_id().expect_local()),
Some(ConstContext::Const | ConstContext::Static(_))
)
ecx.tcx.def_kind(cid.instance.def_id()),
DefKind::Const
| DefKind::Static
| DefKind::ConstParam
| DefKind::AnonConst
| DefKind::AssocConst
),
"Unexpected DefKind: {:?}",
ecx.tcx.def_kind(cid.instance.def_id())
);
let layout = ecx.layout_of(body.return_ty().subst(tcx, cid.instance.substs))?;
assert!(!layout.is_unsized());
Expand All @@ -47,8 +53,6 @@ fn eval_body_using_ecx<'mir, 'tcx>(
let prom = cid.promoted.map_or(String::new(), |p| format!("::promoted[{:?}]", p));
trace!("eval_body_using_ecx: pushing stack frame for global: {}{}", name, prom);



ecx.push_stack_frame(
cid.instance,
body,
Expand Down

0 comments on commit a03feaa

Please sign in to comment.