@@ -14,7 +14,7 @@ use rustc_target::spec::abi::Abi;
14
14
use syntax_pos:: { Pos , Span } ;
15
15
use syntax:: symbol:: Symbol ;
16
16
use hir:: GeneratorKind ;
17
- use std:: { fmt, env} ;
17
+ use std:: { fmt, env, any :: Any } ;
18
18
19
19
use rustc_error_codes:: * ;
20
20
@@ -44,14 +44,14 @@ CloneTypeFoldableImpls! {
44
44
pub type ConstEvalRawResult < ' tcx > = Result < RawConst < ' tcx > , ErrorHandled > ;
45
45
pub type ConstEvalResult < ' tcx > = Result < & ' tcx ty:: Const < ' tcx > , ErrorHandled > ;
46
46
47
- #[ derive( Clone , Debug ) ]
47
+ #[ derive( Debug ) ]
48
48
pub struct ConstEvalErr < ' tcx > {
49
49
pub span : Span ,
50
50
pub error : crate :: mir:: interpret:: InterpError < ' tcx > ,
51
51
pub stacktrace : Vec < FrameInfo < ' tcx > > ,
52
52
}
53
53
54
- #[ derive( Clone , Debug ) ]
54
+ #[ derive( Debug ) ]
55
55
pub struct FrameInfo < ' tcx > {
56
56
/// This span is in the caller.
57
57
pub call_site : Span ,
@@ -138,6 +138,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
138
138
lint_root : Option < hir:: HirId > ,
139
139
) -> Result < DiagnosticBuilder < ' tcx > , ErrorHandled > {
140
140
let must_error = match self . error {
141
+ InterpError :: MachineStop ( _) => bug ! ( "CTFE does not stop" ) ,
141
142
err_inval ! ( Layout ( LayoutError :: Unknown ( _) ) ) |
142
143
err_inval ! ( TooGeneric ) =>
143
144
return Err ( ErrorHandled :: TooGeneric ) ,
@@ -189,7 +190,7 @@ pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'
189
190
/// Thsese should always be constructed by calling `.into()` on
190
191
/// a `InterpError`. In `librustc_mir::interpret`, we have `throw_err_*`
191
192
/// macros for this.
192
- #[ derive( Debug , Clone ) ]
193
+ #[ derive( Debug ) ]
193
194
pub struct InterpErrorInfo < ' tcx > {
194
195
pub kind : InterpError < ' tcx > ,
195
196
backtrace : Option < Box < Backtrace > > ,
@@ -331,7 +332,6 @@ impl<O: fmt::Debug> fmt::Debug for PanicInfo<O> {
331
332
/// Error information for when the program we executed turned out not to actually be a valid
332
333
/// program. This cannot happen in stand-alone Miri, but it can happen during CTFE/ConstProp
333
334
/// where we work on generic code or execution does not have all information available.
334
- #[ derive( Clone , HashStable ) ]
335
335
pub enum InvalidProgramInfo < ' tcx > {
336
336
/// Resolution can fail if we are in a too generic context.
337
337
TooGeneric ,
@@ -361,7 +361,6 @@ impl fmt::Debug for InvalidProgramInfo<'tcx> {
361
361
}
362
362
363
363
/// Error information for when the program caused Undefined Behavior.
364
- #[ derive( Clone , HashStable ) ]
365
364
pub enum UndefinedBehaviorInfo {
366
365
/// Free-form case. Only for errors that are never caught!
367
366
Ub ( String ) ,
@@ -394,7 +393,6 @@ impl fmt::Debug for UndefinedBehaviorInfo {
394
393
///
395
394
/// Currently, we also use this as fall-back error kind for errors that have not been
396
395
/// categorized yet.
397
- #[ derive( Clone , HashStable ) ]
398
396
pub enum UnsupportedOpInfo < ' tcx > {
399
397
/// Free-form case. Only for errors that are never caught!
400
398
Unsupported ( String ) ,
@@ -571,7 +569,6 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
571
569
572
570
/// Error information for when the program exhausted the resources granted to it
573
571
/// by the interpreter.
574
- #[ derive( Clone , HashStable ) ]
575
572
pub enum ResourceExhaustionInfo {
576
573
/// The stack grew too big.
577
574
StackFrameLimitReached ,
@@ -592,7 +589,6 @@ impl fmt::Debug for ResourceExhaustionInfo {
592
589
}
593
590
}
594
591
595
- #[ derive( Clone , HashStable ) ]
596
592
pub enum InterpError < ' tcx > {
597
593
/// The program panicked.
598
594
Panic ( PanicInfo < u64 > ) ,
@@ -601,14 +597,14 @@ pub enum InterpError<'tcx> {
601
597
/// The program did something the interpreter does not support (some of these *might* be UB
602
598
/// but the interpreter is not sure).
603
599
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, ...).
605
601
InvalidProgram ( InvalidProgramInfo < ' tcx > ) ,
606
602
/// The program exhausted the interpreter's resources (stack/heap too big,
607
- /// execution takes too long, ..).
603
+ /// execution takes too long, ... ).
608
604
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 > ) ,
612
608
}
613
609
614
610
pub type InterpResult < ' tcx , T = ( ) > = Result < T , InterpErrorInfo < ' tcx > > ;
@@ -634,8 +630,8 @@ impl fmt::Debug for InterpError<'_> {
634
630
write ! ( f, "{:?}" , msg) ,
635
631
Panic ( ref msg) =>
636
632
write ! ( f, "{:?}" , msg) ,
637
- Exit ( code ) =>
638
- write ! ( f, "exited with status code {}" , code ) ,
633
+ MachineStop ( _ ) =>
634
+ write ! ( f, "machine caused execution to stop" ) ,
639
635
}
640
636
}
641
637
}
0 commit comments