Skip to content

Commit e3427c3

Browse files
committed
Add comments suggested by Niko
1 parent b2bcb72 commit e3427c3

File tree

4 files changed

+9
-27
lines changed

4 files changed

+9
-27
lines changed

src/libsyntax/diagnostic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ pub trait Emitter {
6868
sp: RenderSpan, msg: &str, lvl: Level);
6969
}
7070

71-
/// This structure is used to signify that a task has panicked with a fatal error
72-
/// from the diagnostics. You can use this with the `Any` trait to figure out
73-
/// how a rustc task died (if so desired).
71+
/// Used as a return value to signify a fatal error occurred. (It is also
72+
/// used as the argument to panic at the moment, but that will eventually
73+
/// not be true.)
7474
#[derive(Copy, Clone)]
7575
#[must_use]
7676
pub struct FatalError;

src/libsyntax/ext/asm.rs

-11
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@ use parse::token::InternedString;
2323
use parse::token;
2424
use ptr::P;
2525

26-
macro_rules! panictry {
27-
($e:expr) => ({
28-
use std::result::Result::{Ok, Err};
29-
30-
match $e {
31-
Ok(e) => e,
32-
Err(e) => panic!(e),
33-
}
34-
})
35-
}
36-
3726
enum State {
3827
Asm,
3928
Outputs,

src/libsyntax/ext/format.rs

-11
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,6 @@ use ptr::P;
2424
use std::collections::HashMap;
2525
use std::iter::repeat;
2626

27-
macro_rules! panictry {
28-
($e:expr) => ({
29-
use std::result::Result::{Ok, Err};
30-
31-
match $e {
32-
Ok(e) => e,
33-
Err(e) => { panic!(e); }
34-
}
35-
})
36-
}
37-
3827
#[derive(PartialEq)]
3928
enum ArgumentType {
4029
Known(String),

src/libsyntax/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,17 @@ extern crate libc;
5050

5151
extern crate serialize as rustc_serialize; // used by deriving
5252

53+
// A variant of 'try!' that panics on Err(FatalError). This is used as a
54+
// crutch on the way towards a non-panic!-prone parser. It should be used
55+
// for fatal parsing errors; eventually we plan to convert all code using
56+
// panictry to just use normal try
5357
macro_rules! panictry {
5458
($e:expr) => ({
5559
use std::result::Result::{Ok, Err};
56-
60+
use diagnostic::FatalError;
5761
match $e {
5862
Ok(e) => e,
59-
Err(e) => panic!(e)
63+
Err(FatalError) => panic!(FatalError)
6064
}
6165
})
6266
}

0 commit comments

Comments
 (0)