about summary refs log tree commit diff
path: root/src/libsyntax/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax/lib.rs')
-rw-r--r--src/libsyntax/lib.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index 0980acd3433..bf95daf8755 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -50,6 +50,21 @@ extern crate libc;
 
 extern crate serialize as rustc_serialize; // used by deriving
 
+// A variant of 'try!' that panics on Err(FatalError). This is used as a
+// crutch on the way towards a non-panic!-prone parser. It should be used
+// for fatal parsing errors; eventually we plan to convert all code using
+// panictry to just use normal try
+macro_rules! panictry {
+    ($e:expr) => ({
+        use std::result::Result::{Ok, Err};
+        use diagnostic::FatalError;
+        match $e {
+            Ok(e) => e,
+            Err(FatalError) => panic!(FatalError)
+        }
+    })
+}
+
 pub mod util {
     pub mod interner;
     #[cfg(test)]