11use std:: cell:: RefCell ;
2+ use std:: fmt;
23
34use rustc_span:: DUMMY_SP ;
45
@@ -12,6 +13,26 @@ pub enum TerminationInfo {
1213 ExperimentalUb { msg : String , url : String }
1314}
1415
16+ impl fmt:: Debug for TerminationInfo {
17+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
18+ use TerminationInfo :: * ;
19+ match self {
20+ Exit ( code) =>
21+ write ! ( f, "the evaluated program completed with exit code {}" , code) ,
22+ Abort ( None ) =>
23+ write ! ( f, "the evaluated program aborted execution" ) ,
24+ Abort ( Some ( msg) ) =>
25+ write ! ( f, "the evaluated program aborted execution: {}" , msg) ,
26+ UnsupportedInIsolation ( msg) =>
27+ write ! ( f, "{}" , msg) ,
28+ ExperimentalUb { msg, .. } =>
29+ write ! ( f, "{}" , msg) ,
30+ }
31+ }
32+ }
33+
34+ impl MachineStopType for TerminationInfo { }
35+
1536/// Miri specific diagnostics
1637pub enum NonHaltingDiagnostic {
1738 PoppedTrackedPointerTag ( Item ) ,
@@ -25,21 +46,18 @@ pub fn report_error<'tcx, 'mir>(
2546) -> Option < i64 > {
2647 use InterpError :: * ;
2748
28- e. print_backtrace ( ) ;
29- let ( title, msg, helps) = match e. kind {
30- MachineStop ( info) => {
49+ let ( title, helps) = match e. kind {
50+ MachineStop ( ref info) => {
3151 let info = info. downcast_ref :: < TerminationInfo > ( ) . expect ( "invalid MachineStop payload" ) ;
3252 use TerminationInfo :: * ;
33- let ( title, msg ) = match info {
53+ let title = match info {
3454 Exit ( code) => return Some ( * code) ,
35- Abort ( None ) =>
36- ( "abnormal termination" , format ! ( "the evaluated program aborted execution" ) ) ,
37- Abort ( Some ( msg) ) =>
38- ( "abnormal termination" , format ! ( "the evaluated program aborted execution: {}" , msg) ) ,
39- UnsupportedInIsolation ( msg) =>
40- ( "unsupported operation" , format ! ( "{}" , msg) ) ,
41- ExperimentalUb { msg, .. } =>
42- ( "Undefined Behavior" , format ! ( "{}" , msg) ) ,
55+ Abort ( _) =>
56+ "abnormal termination" ,
57+ UnsupportedInIsolation ( _) =>
58+ "unsupported operation" ,
59+ ExperimentalUb { .. } =>
60+ "Undefined Behavior" ,
4361 } ;
4462 let helps = match info {
4563 UnsupportedInIsolation ( _) =>
@@ -51,16 +69,16 @@ pub fn report_error<'tcx, 'mir>(
5169 ] ,
5270 _ => vec ! [ ] ,
5371 } ;
54- ( title, msg , helps)
72+ ( title, helps)
5573 }
5674 _ => {
57- let ( title, msg ) = match e. kind {
75+ let title = match e. kind {
5876 Unsupported ( _) =>
59- ( "unsupported operation" , e . to_string ( ) ) ,
77+ "unsupported operation" ,
6078 UndefinedBehavior ( _) =>
61- ( "Undefined Behavior" , e . to_string ( ) ) ,
79+ "Undefined Behavior" ,
6280 ResourceExhaustion ( _) =>
63- ( "resource exhaustion" , e . to_string ( ) ) ,
81+ "resource exhaustion" ,
6482 _ =>
6583 bug ! ( "This error should be impossible in Miri: {}" , e) ,
6684 } ;
@@ -76,9 +94,12 @@ pub fn report_error<'tcx, 'mir>(
7694 ] ,
7795 _ => vec ! [ ] ,
7896 } ;
79- ( title, msg , helps)
97+ ( title, helps)
8098 }
8199 } ;
100+
101+ e. print_backtrace ( ) ;
102+ let msg = e. to_string ( ) ;
82103 report_msg ( ecx, & format ! ( "{}: {}" , title, msg) , msg, & helps, true )
83104}
84105
0 commit comments