From e3427c3c341fcd15cbac783bf8dad7276422c97a Mon Sep 17 00:00:00 2001 From: Phil Dawes Date: Sat, 4 Apr 2015 21:47:40 +0100 Subject: Add comments suggested by Niko --- src/libsyntax/diagnostic.rs | 6 +++--- src/libsyntax/ext/asm.rs | 11 ----------- src/libsyntax/ext/format.rs | 11 ----------- src/libsyntax/lib.rs | 8 ++++++-- 4 files changed, 9 insertions(+), 27 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index c746445e77e..8fe23a3c8e8 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -68,9 +68,9 @@ pub trait Emitter { sp: RenderSpan, msg: &str, lvl: Level); } -/// This structure is used to signify that a task has panicked with a fatal error -/// from the diagnostics. You can use this with the `Any` trait to figure out -/// how a rustc task died (if so desired). +/// Used as a return value to signify a fatal error occurred. (It is also +/// used as the argument to panic at the moment, but that will eventually +/// not be true.) #[derive(Copy, Clone)] #[must_use] pub struct FatalError; diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 3513f6d2bb9..f2b45d89f73 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -23,17 +23,6 @@ use parse::token::InternedString; use parse::token; use ptr::P; -macro_rules! panictry { - ($e:expr) => ({ - use std::result::Result::{Ok, Err}; - - match $e { - Ok(e) => e, - Err(e) => panic!(e), - } - }) -} - enum State { Asm, Outputs, diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index fe3a05cfc44..1d99a475b32 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -24,17 +24,6 @@ use ptr::P; use std::collections::HashMap; use std::iter::repeat; -macro_rules! panictry { - ($e:expr) => ({ - use std::result::Result::{Ok, Err}; - - match $e { - Ok(e) => e, - Err(e) => { panic!(e); } - } - }) -} - #[derive(PartialEq)] enum ArgumentType { Known(String), diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index a8b6dae06b9..bf95daf8755 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -50,13 +50,17 @@ 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(e) => panic!(e) + Err(FatalError) => panic!(FatalError) } }) } -- cgit 1.4.1-3-g733a5