@@ -13,17 +13,14 @@ pub use self::RenderSpan::*;
13
13
pub use self :: ColorConfig :: * ;
14
14
use self :: Destination :: * ;
15
15
16
- use codemap:: { COMMAND_LINE_SP , COMMAND_LINE_EXPN , Pos , Span } ;
17
- use codemap;
16
+ use codemap:: { self , COMMAND_LINE_SP , COMMAND_LINE_EXPN , Pos , Span } ;
18
17
use diagnostics;
19
18
20
19
use std:: cell:: { RefCell , Cell } ;
21
- use std:: cmp;
22
- use std:: fmt;
20
+ use std:: { cmp, error, fmt} ;
23
21
use std:: io:: prelude:: * ;
24
22
use std:: io;
25
- use term:: WriterWrapper ;
26
- use term;
23
+ use term:: { self , WriterWrapper } ;
27
24
use libc;
28
25
29
26
/// maximum number of lines we will print for each error; arbitrary.
@@ -83,15 +80,39 @@ pub trait Emitter {
83
80
/// Used as a return value to signify a fatal error occurred. (It is also
84
81
/// used as the argument to panic at the moment, but that will eventually
85
82
/// not be true.)
86
- #[ derive( Copy , Clone ) ]
83
+ #[ derive( Copy , Clone , Debug ) ]
87
84
#[ must_use]
88
85
pub struct FatalError ;
89
86
87
+ impl fmt:: Display for FatalError {
88
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
89
+ write ! ( f, "parser fatal error" )
90
+ }
91
+ }
92
+
93
+ impl error:: Error for FatalError {
94
+ fn description ( & self ) -> & str {
95
+ "The parser has encountered a fatal error"
96
+ }
97
+ }
98
+
90
99
/// Signifies that the compiler died with an explicit call to `.bug`
91
100
/// or `.span_bug` rather than a failed assertion, etc.
92
- #[ derive( Copy , Clone ) ]
101
+ #[ derive( Copy , Clone , Debug ) ]
93
102
pub struct ExplicitBug ;
94
103
104
+ impl fmt:: Display for ExplicitBug {
105
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
106
+ write ! ( f, "parser internal bug" )
107
+ }
108
+ }
109
+
110
+ impl error:: Error for ExplicitBug {
111
+ fn description ( & self ) -> & str {
112
+ "The parser has encountered an internal bug"
113
+ }
114
+ }
115
+
95
116
/// A span-handler is like a handler but also
96
117
/// accepts span information for source-location
97
118
/// reporting.
0 commit comments