File tree Expand file tree Collapse file tree 3 files changed +32
-30
lines changed Expand file tree Collapse file tree 3 files changed +32
-30
lines changed Original file line number Diff line number Diff line change @@ -259,36 +259,7 @@ impl CodeSuggestion {
259259 }
260260}
261261
262- /// Used as a return value to signify a fatal error occurred. (It is also
263- /// used as the argument to panic at the moment, but that will eventually
264- /// not be true.)
265- #[ derive( Copy , Clone , Debug ) ]
266- #[ must_use]
267- pub struct FatalError ;
268-
269- pub struct FatalErrorMarker ;
270-
271- // Don't implement Send on FatalError. This makes it impossible to panic!(FatalError).
272- // We don't want to invoke the panic handler and print a backtrace for fatal errors.
273- impl !Send for FatalError { }
274-
275- impl FatalError {
276- pub fn raise ( self ) -> ! {
277- panic:: resume_unwind ( Box :: new ( FatalErrorMarker ) )
278- }
279- }
280-
281- impl fmt:: Display for FatalError {
282- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
283- write ! ( f, "parser fatal error" )
284- }
285- }
286-
287- impl error:: Error for FatalError {
288- fn description ( & self ) -> & str {
289- "The parser has encountered a fatal error"
290- }
291- }
262+ pub use syntax_pos:: fatal_error:: { FatalError , FatalErrorMarker } ;
292263
293264/// Signifies that the compiler died with an explicit call to `.bug`
294265/// or `.span_bug` rather than a failed assertion, etc.
Original file line number Diff line number Diff line change 1+ /// Used as a return value to signify a fatal error occurred. (It is also
2+ /// used as the argument to panic at the moment, but that will eventually
3+ /// not be true.)
4+ #[ derive( Copy , Clone , Debug ) ]
5+ #[ must_use]
6+ pub struct FatalError ;
7+
8+ pub struct FatalErrorMarker ;
9+
10+ // Don't implement Send on FatalError. This makes it impossible to panic!(FatalError).
11+ // We don't want to invoke the panic handler and print a backtrace for fatal errors.
12+ impl !Send for FatalError { }
13+
14+ impl FatalError {
15+ pub fn raise ( self ) -> ! {
16+ std:: panic:: resume_unwind ( Box :: new ( FatalErrorMarker ) )
17+ }
18+ }
19+
20+ impl std:: fmt:: Display for FatalError {
21+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
22+ write ! ( f, "parser fatal error" )
23+ }
24+ }
25+
26+ impl std:: error:: Error for FatalError {
27+ fn description ( & self ) -> & str {
28+ "The parser has encountered a fatal error"
29+ }
30+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ pub mod symbol;
2929pub use symbol:: { Symbol , sym} ;
3030
3131mod analyze_source_file;
32+ pub mod fatal_error;
3233
3334use rustc_data_structures:: stable_hasher:: StableHasher ;
3435use rustc_data_structures:: sync:: { Lrc , Lock } ;
You can’t perform that action at this time.
0 commit comments