1 // Not in interpret to make sure we do not use private implementation details
5 use std::borrow::{Borrow, Cow};
7 use std::collections::hash_map::Entry;
9 use rustc::hir::{self, def_id::DefId};
10 use rustc::hir::def::Def;
11 use rustc::mir::interpret::{ConstEvalErr, ErrorHandled};
13 use rustc::ty::{self, TyCtxt, Instance, query::TyCtxtAt};
14 use rustc::ty::layout::{self, LayoutOf, TyLayout, VariantIdx};
15 use rustc::ty::subst::Subst;
16 use rustc::traits::Reveal;
17 use rustc_data_structures::indexed_vec::IndexVec;
18 use rustc_data_structures::fx::FxHashMap;
19 use rustc::util::common::ErrorReported;
21 use syntax::ast::Mutability;
22 use syntax::source_map::{Span, DUMMY_SP};
24 use crate::interpret::{self,
25 PlaceTy, MPlaceTy, MemPlace, OpTy, Operand, Immediate, Scalar, RawConst, ConstValue, Pointer,
26 EvalResult, EvalError, EvalErrorKind, GlobalId, EvalContext, StackPopCleanup,
27 Allocation, AllocId, MemoryKind,
28 snapshot, RefTracking,
31 /// Number of steps until the detector even starts doing anything.
32 /// Also, a warning is shown to the user when this number is reached.
33 const STEPS_UNTIL_DETECTOR_ENABLED: isize = 1_000_000;
34 /// The number of steps between loop detector snapshots.
35 /// Should be a power of two for performance reasons.
36 const DETECTOR_SNAPSHOT_PERIOD: isize = 256;
38 pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>(
39 tcx: TyCtxt<'a, 'tcx, 'tcx>,
40 instance: Instance<'tcx>,
41 mir: &'mir mir::Mir<'tcx>,
43 ) -> EvalResult<'tcx, CompileTimeEvalContext<'a, 'mir, 'tcx>> {
44 debug!("mk_borrowck_eval_cx: {:?}", instance);
45 let param_env = tcx.param_env(instance.def_id());
46 let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new());
47 // insert a stack frame so any queries have the correct substs
48 // cannot use `push_stack_frame`; if we do `const_prop` explodes
49 ecx.stack.push(interpret::Frame {
50 block: mir::START_BLOCK,
51 locals: IndexVec::new(),
56 return_to_block: StackPopCleanup::Goto(None), // never pop
63 pub fn mk_eval_cx<'a, 'tcx>(
64 tcx: TyCtxt<'a, 'tcx, 'tcx>,
65 instance: Instance<'tcx>,
66 param_env: ty::ParamEnv<'tcx>,
67 ) -> EvalResult<'tcx, CompileTimeEvalContext<'a, 'tcx, 'tcx>> {
68 debug!("mk_eval_cx: {:?}, {:?}", instance, param_env);
69 let span = tcx.def_span(instance.def_id());
70 let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new());
71 let mir = ecx.load_mir(instance.def)?;
72 // insert a stack frame so any queries have the correct substs
78 StackPopCleanup::Goto(None), // never pop
83 pub(crate) fn eval_promoted<'a, 'mir, 'tcx>(
84 tcx: TyCtxt<'a, 'tcx, 'tcx>,
86 mir: &'mir mir::Mir<'tcx>,
87 param_env: ty::ParamEnv<'tcx>,
88 ) -> EvalResult<'tcx, MPlaceTy<'tcx>> {
89 let mut ecx = mk_borrowck_eval_cx(tcx, cid.instance, mir, DUMMY_SP).unwrap();
90 eval_body_using_ecx(&mut ecx, cid, Some(mir), param_env)
93 // FIXME: These two conversion functions are bad hacks. We should just always use allocations.
94 pub fn op_to_const<'tcx>(
95 ecx: &CompileTimeEvalContext<'_, '_, 'tcx>,
98 ) -> EvalResult<'tcx, &'tcx ty::Const<'tcx>> {
99 // We do not normalize just any data. Only scalar layout and fat pointers.
100 let normalize = may_normalize
101 && match op.layout.abi {
102 layout::Abi::Scalar(..) => true,
103 layout::Abi::ScalarPair(..) => {
104 // Must be a fat pointer
105 op.layout.ty.builtin_deref(true).is_some()
109 let normalized_op = if normalize {
110 ecx.try_read_immediate(op)?
113 Operand::Indirect(mplace) => Err(mplace),
114 Operand::Immediate(val) => Ok(val)
117 let val = match normalized_op {
118 Err(MemPlace { ptr, align, meta }) => {
119 // extract alloc-offset pair
120 assert!(meta.is_none());
121 let ptr = ptr.to_ptr()?;
122 let alloc = ecx.memory.get(ptr.alloc_id)?;
123 assert!(alloc.align >= align);
124 assert!(alloc.bytes.len() as u64 - ptr.offset.bytes() >= op.layout.size.bytes());
125 let mut alloc = alloc.clone();
127 // FIXME shouldn't it be the case that `mark_static_initialized` has already
128 // interned this? I thought that is the entire point of that `FinishStatic` stuff?
129 let alloc = ecx.tcx.intern_const_alloc(alloc);
130 ConstValue::ByRef(ptr.alloc_id, alloc, ptr.offset)
132 Ok(Immediate::Scalar(x)) =>
133 ConstValue::Scalar(x.not_undef()?),
134 Ok(Immediate::ScalarPair(a, b)) =>
135 ConstValue::ScalarPair(a.not_undef()?, b.not_undef()?),
137 Ok(ty::Const::from_const_value(ecx.tcx.tcx, val, op.layout.ty))
139 pub fn const_to_op<'tcx>(
140 ecx: &CompileTimeEvalContext<'_, '_, 'tcx>,
141 cnst: &ty::Const<'tcx>,
142 ) -> EvalResult<'tcx, OpTy<'tcx>> {
143 let op = ecx.const_value_to_op(cnst.val)?;
144 Ok(OpTy { op, layout: ecx.layout_of(cnst.ty)? })
147 fn eval_body_and_ecx<'a, 'mir, 'tcx>(
148 tcx: TyCtxt<'a, 'tcx, 'tcx>,
150 mir: Option<&'mir mir::Mir<'tcx>>,
151 param_env: ty::ParamEnv<'tcx>,
152 ) -> (EvalResult<'tcx, MPlaceTy<'tcx>>, CompileTimeEvalContext<'a, 'mir, 'tcx>) {
153 // we start out with the best span we have
154 // and try improving it down the road when more information is available
155 let span = tcx.def_span(cid.instance.def_id());
156 let span = mir.map(|mir| mir.span).unwrap_or(span);
157 let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new());
158 let r = eval_body_using_ecx(&mut ecx, cid, mir, param_env);
162 // Returns a pointer to where the result lives
163 fn eval_body_using_ecx<'mir, 'tcx>(
164 ecx: &mut CompileTimeEvalContext<'_, 'mir, 'tcx>,
166 mir: Option<&'mir mir::Mir<'tcx>>,
167 param_env: ty::ParamEnv<'tcx>,
168 ) -> EvalResult<'tcx, MPlaceTy<'tcx>> {
169 debug!("eval_body_using_ecx: {:?}, {:?}", cid, param_env);
170 let tcx = ecx.tcx.tcx;
171 let mut mir = match mir {
173 None => ecx.load_mir(cid.instance.def)?,
175 if let Some(index) = cid.promoted {
176 mir = &mir.promoted[index];
178 let layout = ecx.layout_of(mir.return_ty().subst(tcx, cid.instance.substs))?;
179 assert!(!layout.is_unsized());
180 let ret = ecx.allocate(layout, MemoryKind::Stack);
182 let name = ty::tls::with(|tcx| tcx.item_path_str(cid.instance.def_id()));
183 let prom = cid.promoted.map_or(String::new(), |p| format!("::promoted[{:?}]", p));
184 trace!("eval_body_using_ecx: pushing stack frame for global: {}{}", name, prom);
185 assert!(mir.arg_count == 0);
186 ecx.push_stack_frame(
191 StackPopCleanup::None { cleanup: false },
194 // The main interpreter loop.
198 let internally_mutable = !layout.ty.is_freeze(tcx, param_env, mir.span);
199 let is_static = tcx.is_static(cid.instance.def_id());
200 let mutability = if is_static == Some(hir::Mutability::MutMutable) || internally_mutable {
203 Mutability::Immutable
205 ecx.memory.intern_static(ret.ptr.to_ptr()?.alloc_id, mutability)?;
207 debug!("eval_body_using_ecx done: {:?}", *ret);
211 impl<'tcx> Into<EvalError<'tcx>> for ConstEvalError {
212 fn into(self) -> EvalError<'tcx> {
213 EvalErrorKind::MachineError(self.to_string()).into()
217 #[derive(Clone, Debug)]
218 enum ConstEvalError {
222 impl fmt::Display for ConstEvalError {
223 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
224 use self::ConstEvalError::*;
226 NeedsRfc(ref msg) => {
229 "\"{}\" needs an rfc before being allowed inside constants",
237 impl Error for ConstEvalError {
238 fn description(&self) -> &str {
239 use self::ConstEvalError::*;
241 NeedsRfc(_) => "this feature needs an rfc before being allowed inside constants",
245 fn cause(&self) -> Option<&dyn Error> {
250 // Extra machine state for CTFE, and the Machine instance
251 pub struct CompileTimeInterpreter<'a, 'mir, 'tcx: 'a+'mir> {
252 /// When this value is negative, it indicates the number of interpreter
253 /// steps *until* the loop detector is enabled. When it is positive, it is
254 /// the number of steps after the detector has been enabled modulo the loop
256 pub(super) steps_since_detector_enabled: isize,
258 /// Extra state to detect loops.
259 pub(super) loop_detector: snapshot::InfiniteLoopDetector<'a, 'mir, 'tcx>,
262 impl<'a, 'mir, 'tcx> CompileTimeInterpreter<'a, 'mir, 'tcx> {
264 CompileTimeInterpreter {
265 loop_detector: Default::default(),
266 steps_since_detector_enabled: -STEPS_UNTIL_DETECTOR_ENABLED,
271 impl<K: Hash + Eq, V> interpret::AllocMap<K, V> for FxHashMap<K, V> {
273 fn contains_key<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> bool
276 FxHashMap::contains_key(self, k)
280 fn insert(&mut self, k: K, v: V) -> Option<V>
282 FxHashMap::insert(self, k, v)
286 fn remove<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> Option<V>
289 FxHashMap::remove(self, k)
293 fn filter_map_collect<T>(&self, mut f: impl FnMut(&K, &V) -> Option<T>) -> Vec<T> {
295 .filter_map(move |(k, v)| f(k, &*v))
303 vacant: impl FnOnce() -> Result<V, E>
310 bug!("The CTFE machine shouldn't ever need to extend the alloc_map when reading")
319 vacant: impl FnOnce() -> Result<V, E>
320 ) -> Result<&mut V, E>
322 match self.entry(k) {
323 Entry::Occupied(e) => Ok(e.into_mut()),
324 Entry::Vacant(e) => {
332 type CompileTimeEvalContext<'a, 'mir, 'tcx> =
333 EvalContext<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>;
335 impl interpret::MayLeak for ! {
337 fn may_leak(self) -> bool {
338 // `self` is uninhabited
343 impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
344 for CompileTimeInterpreter<'a, 'mir, 'tcx>
346 type MemoryKinds = !;
347 type PointerTag = ();
349 type FrameExtra = ();
350 type MemoryExtra = ();
351 type AllocExtra = ();
353 type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
355 const STATIC_KIND: Option<!> = None; // no copying of statics allowed
358 fn enforce_validity(_ecx: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool {
359 false // for now, we don't enforce validity
363 ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>,
364 instance: ty::Instance<'tcx>,
366 dest: Option<PlaceTy<'tcx>>,
367 ret: Option<mir::BasicBlock>,
368 ) -> EvalResult<'tcx, Option<&'mir mir::Mir<'tcx>>> {
369 debug!("eval_fn_call: {:?}", instance);
370 // Execution might have wandered off into other crates, so we cannot to a stability-
371 // sensitive check here. But we can at least rule out functions that are not const
373 if !ecx.tcx.is_const_fn_raw(instance.def_id()) {
374 // Some functions we support even if they are non-const -- but avoid testing
375 // that for const fn! We certainly do *not* want to actually call the fn
376 // though, so be sure we return here.
377 return if ecx.hook_fn(instance, args, dest)? {
378 ecx.goto_block(ret)?; // fully evaluated and done
381 err!(MachineError(format!("calling non-const function `{}`", instance)))
384 // This is a const fn. Call it.
385 Ok(Some(match ecx.load_mir(instance.def) {
388 if let EvalErrorKind::NoMirFor(ref path) = err.kind {
390 ConstEvalError::NeedsRfc(format!("calling extern function `{}`", path))
400 ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>,
401 instance: ty::Instance<'tcx>,
404 ) -> EvalResult<'tcx> {
405 if ecx.emulate_intrinsic(instance, args, dest)? {
408 // An intrinsic that we do not support
409 let intrinsic_name = &ecx.tcx.item_name(instance.def_id()).as_str()[..];
411 ConstEvalError::NeedsRfc(format!("calling intrinsic `{}`", intrinsic_name)).into()
416 _ecx: &EvalContext<'a, 'mir, 'tcx, Self>,
419 _left_layout: TyLayout<'tcx>,
421 _right_layout: TyLayout<'tcx>,
422 ) -> EvalResult<'tcx, (Scalar, bool)> {
424 ConstEvalError::NeedsRfc("pointer arithmetic or comparison".to_string()).into(),
428 fn find_foreign_static(
430 _tcx: TyCtxtAt<'a, 'tcx, 'tcx>,
432 ) -> EvalResult<'tcx, Cow<'tcx, Allocation<Self::PointerTag>>> {
433 err!(ReadForeignStatic)
437 fn adjust_static_allocation<'b>(
438 alloc: &'b Allocation,
440 ) -> Cow<'b, Allocation<Self::PointerTag>> {
441 // We do not use a tag so we can just cheaply forward the reference
446 _ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>,
447 _dest: PlaceTy<'tcx>,
448 ) -> EvalResult<'tcx> {
450 ConstEvalError::NeedsRfc("heap allocations via `box` keyword".to_string()).into(),
454 fn before_terminator(ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> {
456 let steps = &mut ecx.machine.steps_since_detector_enabled;
463 *steps %= DETECTOR_SNAPSHOT_PERIOD;
469 let span = ecx.frame().span;
470 ecx.machine.loop_detector.observe_and_analyze(
479 fn tag_new_allocation(
480 _ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>,
482 _kind: MemoryKind<Self::MemoryKinds>,
489 _ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>,
490 ) -> EvalResult<'tcx> {
494 /// Called immediately before a stack frame gets popped
497 _ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>,
499 ) -> EvalResult<'tcx> {
504 /// Project to a field of a (variant of a) const
505 pub fn const_field<'a, 'tcx>(
506 tcx: TyCtxt<'a, 'tcx, 'tcx>,
507 param_env: ty::ParamEnv<'tcx>,
508 instance: ty::Instance<'tcx>,
509 variant: Option<VariantIdx>,
511 value: &'tcx ty::Const<'tcx>,
512 ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
513 trace!("const_field: {:?}, {:?}, {:?}", instance, field, value);
514 let ecx = mk_eval_cx(tcx, instance, param_env).unwrap();
516 // get the operand again
517 let op = const_to_op(&ecx, value)?;
519 let down = match variant {
521 Some(variant) => ecx.operand_downcast(op, variant)?
524 let field = ecx.operand_field(down, field.index() as u64)?;
525 // and finally move back to the const world, always normalizing because
526 // this is not called for statics.
527 op_to_const(&ecx, field, true)
529 result.map_err(|error| {
530 let err = error_to_const_error(&ecx, error);
531 err.report_as_error(ecx.tcx, "could not access field of constant");
532 ErrorHandled::Reported
536 pub fn const_variant_index<'a, 'tcx>(
537 tcx: TyCtxt<'a, 'tcx, 'tcx>,
538 param_env: ty::ParamEnv<'tcx>,
539 instance: ty::Instance<'tcx>,
540 val: &'tcx ty::Const<'tcx>,
541 ) -> EvalResult<'tcx, VariantIdx> {
542 trace!("const_variant_index: {:?}, {:?}", instance, val);
543 let ecx = mk_eval_cx(tcx, instance, param_env).unwrap();
544 let op = const_to_op(&ecx, val)?;
545 Ok(ecx.read_discriminant(op)?.1)
548 pub fn error_to_const_error<'a, 'mir, 'tcx>(
549 ecx: &EvalContext<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>,
550 mut error: EvalError<'tcx>
551 ) -> ConstEvalErr<'tcx> {
552 error.print_backtrace();
553 let stacktrace = ecx.generate_stacktrace(None);
554 ConstEvalErr { error: error.kind, stacktrace, span: ecx.tcx.span }
557 fn validate_and_turn_into_const<'a, 'tcx>(
558 tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
559 constant: RawConst<'tcx>,
560 key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
561 ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
563 let ecx = mk_eval_cx(tcx, cid.instance, key.param_env).unwrap();
565 let op = ecx.raw_const_to_mplace(constant)?.into();
566 // FIXME: Once the visitor infrastructure landed, change validation to
567 // work directly on `MPlaceTy`.
568 let mut ref_tracking = RefTracking::new(op);
569 while let Some((op, path)) = ref_tracking.todo.pop() {
570 ecx.validate_operand(
573 Some(&mut ref_tracking),
574 /* const_mode */ true,
577 // Now that we validated, turn this into a proper constant
578 let def_id = cid.instance.def.def_id();
579 let normalize = tcx.is_static(def_id).is_none() && cid.promoted.is_none();
580 op_to_const(&ecx, op, normalize)
583 val.map_err(|error| {
584 let err = error_to_const_error(&ecx, error);
585 match err.struct_error(ecx.tcx, "it is undefined behavior to use this value") {
587 diag.note("The rules on what exactly is undefined behavior aren't clear, \
588 so this check might be overzealous. Please open an issue on the rust compiler \
589 repository if you believe it should not be considered undefined behavior",
592 ErrorHandled::Reported
599 pub fn const_eval_provider<'a, 'tcx>(
600 tcx: TyCtxt<'a, 'tcx, 'tcx>,
601 key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
602 ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
603 // see comment in const_eval_provider for what we're doing here
604 if key.param_env.reveal == Reveal::All {
605 let mut key = key.clone();
606 key.param_env.reveal = Reveal::UserFacing;
607 match tcx.const_eval(key) {
608 // try again with reveal all as requested
609 Err(ErrorHandled::TooGeneric) => {
610 // Promoteds should never be "too generic" when getting evaluated.
611 // They either don't get evaluated, or we are in a monomorphic context
612 assert!(key.value.promoted.is_none());
615 other => return other,
618 tcx.const_eval_raw(key).and_then(|val| {
619 validate_and_turn_into_const(tcx, val, key)
623 pub fn const_eval_raw_provider<'a, 'tcx>(
624 tcx: TyCtxt<'a, 'tcx, 'tcx>,
625 key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
626 ) -> ::rustc::mir::interpret::ConstEvalRawResult<'tcx> {
627 // Because the constant is computed twice (once per value of `Reveal`), we are at risk of
628 // reporting the same error twice here. To resolve this, we check whether we can evaluate the
629 // constant in the more restrictive `Reveal::UserFacing`, which most likely already was
630 // computed. For a large percentage of constants that will already have succeeded. Only
631 // associated constants of generic functions will fail due to not enough monomorphization
632 // information being available.
634 // In case we fail in the `UserFacing` variant, we just do the real computation.
635 if key.param_env.reveal == Reveal::All {
636 let mut key = key.clone();
637 key.param_env.reveal = Reveal::UserFacing;
638 match tcx.const_eval_raw(key) {
639 // try again with reveal all as requested
640 Err(ErrorHandled::TooGeneric) => {},
642 other => return other,
645 // the first trace is for replicating an ice
646 // There's no tracking issue, but the next two lines concatenated link to the discussion on
647 // zulip. It's not really possible to test this, because it doesn't show up in diagnostics
649 // https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/
650 // subject/anon_const_instance_printing/near/135980032
651 trace!("const eval: {}", key.value.instance);
652 trace!("const eval: {:?}", key);
655 let def_id = cid.instance.def.def_id();
657 if let Some(id) = tcx.hir().as_local_node_id(def_id) {
658 let tables = tcx.typeck_tables_of(def_id);
660 // Do match-check before building MIR
661 if let Err(ErrorReported) = tcx.check_match(def_id) {
662 return Err(ErrorHandled::Reported)
665 if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind(id) {
666 tcx.mir_const_qualif(def_id);
669 // Do not continue into miri if typeck errors occurred; it will fail horribly
670 if tables.tainted_by_errors {
671 return Err(ErrorHandled::Reported)
675 let (res, ecx) = eval_body_and_ecx(tcx, cid, None, key.param_env);
676 res.and_then(|place| {
678 alloc_id: place.to_ptr().expect("we allocated this ptr!").alloc_id,
682 let err = error_to_const_error(&ecx, error);
683 // errors in statics are always emitted as fatal errors
684 if tcx.is_static(def_id).is_some() {
685 let reported_err = err.report_as_error(ecx.tcx,
686 "could not evaluate static initializer");
687 // Ensure that if the above error was either `TooGeneric` or `Reported`
688 // an error must be reported.
689 if tcx.sess.err_count() == 0 {
690 tcx.sess.delay_span_bug(err.span,
691 &format!("static eval failure did not emit an error: {:#?}",
695 } else if def_id.is_local() {
696 // constant defined in this crate, we can figure out a lint level!
697 match tcx.describe_def(def_id) {
698 // constants never produce a hard error at the definition site. Anything else is
699 // a backwards compatibility hazard (and will break old versions of winapi for sure)
701 // note that validation may still cause a hard error on this very same constant,
702 // because any code that existed before validation could not have failed validation
703 // thus preventing such a hard error from being a backwards compatibility hazard
704 Some(Def::Const(_)) | Some(Def::AssociatedConst(_)) => {
705 let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
707 tcx.at(tcx.def_span(def_id)),
708 "any use of this value will cause an error",
712 // promoting runtime code is only allowed to error if it references broken constants
713 // any other kind of error will be reported to the user as a deny-by-default lint
714 _ => if let Some(p) = cid.promoted {
715 let span = tcx.optimized_mir(def_id).promoted[p].span;
716 if let EvalErrorKind::ReferencedConstant = err.error {
719 "evaluation of constant expression failed",
724 "reaching this expression at runtime will panic or abort",
725 tcx.hir().as_local_node_id(def_id).unwrap(),
728 // anything else (array lengths, enum initializers, constant patterns) are reported
733 "evaluation of constant value failed",
738 // use of broken constant from other crate
739 err.report_as_error(ecx.tcx, "could not evaluate constant")