@@ -14,7 +14,7 @@ use rustc_target::spec::abi::Abi;
1414use syntax_pos:: { Pos , Span } ;
1515use syntax:: symbol:: Symbol ;
1616use hir:: GeneratorKind ;
17- use std:: { fmt, env} ;
17+ use std:: { fmt, env, any :: Any } ;
1818
1919use rustc_error_codes:: * ;
2020
@@ -44,14 +44,14 @@ CloneTypeFoldableImpls! {
4444pub type ConstEvalRawResult < ' tcx > = Result < RawConst < ' tcx > , ErrorHandled > ;
4545pub type ConstEvalResult < ' tcx > = Result < & ' tcx ty:: Const < ' tcx > , ErrorHandled > ;
4646
47- #[ derive( Clone , Debug ) ]
47+ #[ derive( Debug ) ]
4848pub struct ConstEvalErr < ' tcx > {
4949 pub span : Span ,
5050 pub error : crate :: mir:: interpret:: InterpError < ' tcx > ,
5151 pub stacktrace : Vec < FrameInfo < ' tcx > > ,
5252}
5353
54- #[ derive( Clone , Debug ) ]
54+ #[ derive( Debug ) ]
5555pub struct FrameInfo < ' tcx > {
5656 /// This span is in the caller.
5757 pub call_site : Span ,
@@ -138,6 +138,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
138138 lint_root : Option < hir:: HirId > ,
139139 ) -> Result < DiagnosticBuilder < ' tcx > , ErrorHandled > {
140140 let must_error = match self . error {
141+ InterpError :: MachineStop ( _) => bug ! ( "CTFE does not stop" ) ,
141142 err_inval ! ( Layout ( LayoutError :: Unknown ( _) ) ) |
142143 err_inval ! ( TooGeneric ) =>
143144 return Err ( ErrorHandled :: TooGeneric ) ,
@@ -189,7 +190,7 @@ pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'
189190/// Thsese should always be constructed by calling `.into()` on
190191/// a `InterpError`. In `librustc_mir::interpret`, we have `throw_err_*`
191192/// macros for this.
192- #[ derive( Debug , Clone ) ]
193+ #[ derive( Debug ) ]
193194pub struct InterpErrorInfo < ' tcx > {
194195 pub kind : InterpError < ' tcx > ,
195196 backtrace : Option < Box < Backtrace > > ,
@@ -331,7 +332,6 @@ impl<O: fmt::Debug> fmt::Debug for PanicInfo<O> {
331332/// Error information for when the program we executed turned out not to actually be a valid
332333/// program. This cannot happen in stand-alone Miri, but it can happen during CTFE/ConstProp
333334/// where we work on generic code or execution does not have all information available.
334- #[ derive( Clone , HashStable ) ]
335335pub enum InvalidProgramInfo < ' tcx > {
336336 /// Resolution can fail if we are in a too generic context.
337337 TooGeneric ,
@@ -361,7 +361,6 @@ impl fmt::Debug for InvalidProgramInfo<'tcx> {
361361}
362362
363363/// Error information for when the program caused Undefined Behavior.
364- #[ derive( Clone , HashStable ) ]
365364pub enum UndefinedBehaviorInfo {
366365 /// Free-form case. Only for errors that are never caught!
367366 Ub ( String ) ,
@@ -394,7 +393,6 @@ impl fmt::Debug for UndefinedBehaviorInfo {
394393///
395394/// Currently, we also use this as fall-back error kind for errors that have not been
396395/// categorized yet.
397- #[ derive( Clone , HashStable ) ]
398396pub enum UnsupportedOpInfo < ' tcx > {
399397 /// Free-form case. Only for errors that are never caught!
400398 Unsupported ( String ) ,
@@ -571,7 +569,6 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
571569
572570/// Error information for when the program exhausted the resources granted to it
573571/// by the interpreter.
574- #[ derive( Clone , HashStable ) ]
575572pub enum ResourceExhaustionInfo {
576573 /// The stack grew too big.
577574 StackFrameLimitReached ,
@@ -592,7 +589,6 @@ impl fmt::Debug for ResourceExhaustionInfo {
592589 }
593590}
594591
595- #[ derive( Clone , HashStable ) ]
596592pub enum InterpError < ' tcx > {
597593 /// The program panicked.
598594 Panic ( PanicInfo < u64 > ) ,
@@ -601,14 +597,14 @@ pub enum InterpError<'tcx> {
601597 /// The program did something the interpreter does not support (some of these *might* be UB
602598 /// but the interpreter is not sure).
603599 Unsupported ( UnsupportedOpInfo < ' tcx > ) ,
604- /// The program was invalid (ill-typed, not sufficiently monomorphized, ...).
600+ /// The program was invalid (ill-typed, bad MIR, not sufficiently monomorphized, ...).
605601 InvalidProgram ( InvalidProgramInfo < ' tcx > ) ,
606602 /// The program exhausted the interpreter's resources (stack/heap too big,
607- /// execution takes too long, ..).
603+ /// execution takes too long, ... ).
608604 ResourceExhaustion ( ResourceExhaustionInfo ) ,
609- /// Not actually an interpreter error -- used to signal that execution has exited
610- /// with the given status code. Used by Miri, but not by CTFE .
611- Exit ( i32 ) ,
605+ /// Stop execution for a machine-controlled reason. This is never raised by
606+ /// the core engine itself .
607+ MachineStop ( Box < dyn Any + Send > ) ,
612608}
613609
614610pub type InterpResult < ' tcx , T = ( ) > = Result < T , InterpErrorInfo < ' tcx > > ;
@@ -634,8 +630,8 @@ impl fmt::Debug for InterpError<'_> {
634630 write ! ( f, "{:?}" , msg) ,
635631 Panic ( ref msg) =>
636632 write ! ( f, "{:?}" , msg) ,
637- Exit ( code ) =>
638- write ! ( f, "exited with status code {}" , code ) ,
633+ MachineStop ( _ ) =>
634+ write ! ( f, "machine caused execution to stop" ) ,
639635 }
640636 }
641637}
0 commit comments