]> git.lizzy.rs Git - rust.git/commitdiff
Merge branch 'no-stderr-sink' of https://github.com/Zoxc/rust into rollup
authorAlex Crichton <alex@alexcrichton.com>
Fri, 26 Jan 2018 14:49:55 +0000 (06:49 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 26 Jan 2018 14:49:55 +0000 (06:49 -0800)
19 files changed:
src/librustc/hir/lowering.rs
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc_driver/lib.rs
src/librustc_errors/lib.rs
src/librustc_trans/back/write.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/expand.rs
src/libsyntax/ext/source_util.rs
src/libsyntax/ext/tt/macro_parser.rs
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/feature_gate.rs
src/libsyntax/lib.rs
src/libsyntax/parse/lexer/comments.rs
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/mod.rs
src/libsyntax/test.rs
src/libsyntax_ext/deriving/custom.rs
src/libsyntax_ext/proc_macro_impl.rs

index dc2f2583c0177c1ddc687b2b2175f739894e620e..f2f420c91dd1a1455375f7f9f5afbca70784de2c 100644 (file)
@@ -2837,8 +2837,8 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                     (&None, &Some(..), Closed) => "RangeToInclusive",
                     (&Some(..), &Some(..), Closed) => "RangeInclusive",
                     (_, &None, Closed) =>
-                        panic!(self.diagnostic().span_fatal(
-                            e.span, "inclusive range with no end")),
+                        self.diagnostic().span_fatal(
+                            e.span, "inclusive range with no end").raise(),
                 };
 
                 let fields =
index 3fac9ce41f1397e1fed9a6b41c1108665e2f7b4b..a4f347d4687877031d2311400a08e0482278a7cc 100644 (file)
@@ -1365,7 +1365,7 @@ pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
             sp.struct_fatal(&format!("Error loading target specification: {}", e))
                 .help("Use `--print target-list` for a list of built-in targets")
                 .emit();
-            panic!(FatalError);
+            FatalError.raise();
         }
     };
 
@@ -1373,8 +1373,8 @@ pub fn build_target_config(opts: &Options, sp: &Handler) -> Config {
         "16" => (ast::IntTy::I16, ast::UintTy::U16),
         "32" => (ast::IntTy::I32, ast::UintTy::U32),
         "64" => (ast::IntTy::I64, ast::UintTy::U64),
-        w    => panic!(sp.fatal(&format!("target specification was invalid: \
-                                          unrecognized target-pointer-width {}", w))),
+        w    => sp.fatal(&format!("target specification was invalid: \
+                                          unrecognized target-pointer-width {}", w)).raise(),
     };
 
     Config {
index 02cd6a92eb7618b43847978e80eb6cc40c76ce51..568ae77c964c8f3782173d36e94cd766bd22bd85 100644 (file)
@@ -250,7 +250,7 @@ pub fn struct_fatal<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a>  {
     }
 
     pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
-        panic!(self.diagnostic().span_fatal(sp, msg))
+        self.diagnostic().span_fatal(sp, msg).raise()
     }
     pub fn span_fatal_with_code<S: Into<MultiSpan>>(
         &self,
@@ -258,10 +258,10 @@ pub fn span_fatal_with_code<S: Into<MultiSpan>>(
         msg: &str,
         code: DiagnosticId,
     ) -> ! {
-        panic!(self.diagnostic().span_fatal_with_code(sp, msg, code))
+        self.diagnostic().span_fatal_with_code(sp, msg, code).raise()
     }
     pub fn fatal(&self, msg: &str) -> ! {
-        panic!(self.diagnostic().fatal(msg))
+        self.diagnostic().fatal(msg).raise()
     }
     pub fn span_err_or_warn<S: Into<MultiSpan>>(&self, is_warning: bool, sp: S, msg: &str) {
         if is_warning {
@@ -943,7 +943,7 @@ pub fn build_session_(sopts: config::Options,
     let host = match Target::search(config::host_triple()) {
         Ok(t) => t,
         Err(e) => {
-            panic!(span_diagnostic.fatal(&format!("Error loading host specification: {}", e)));
+            span_diagnostic.fatal(&format!("Error loading host specification: {}", e)).raise();
         }
     };
     let target_cfg = config::build_target_config(&sopts, &span_diagnostic);
@@ -969,7 +969,7 @@ pub fn build_session_(sopts: config::Options,
     let working_dir = match env::current_dir() {
         Ok(dir) => dir,
         Err(e) => {
-            panic!(p_s.span_diagnostic.fatal(&format!("Current directory is invalid: {}", e)))
+            p_s.span_diagnostic.fatal(&format!("Current directory is invalid: {}", e)).raise()
         }
     };
     let working_dir = file_path_mapping.map_prefix(working_dir);
@@ -1100,7 +1100,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
     };
     let handler = errors::Handler::with_emitter(true, false, emitter);
     handler.emit(&MultiSpan::new(), msg, errors::Level::Fatal);
-    panic!(errors::FatalError);
+    errors::FatalError.raise();
 }
 
 pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
index e737328b75ea6befe321217d76fcef7aa24105d4..cdb50a0ae48507a90d180fb1b9e32aaaa4f9a4c5 100644 (file)
 use std::ffi::OsString;
 use std::io::{self, Read, Write};
 use std::iter::repeat;
+use std::panic;
 use std::path::PathBuf;
 use std::process::{self, Command, Stdio};
 use std::rc::Rc;
 use std::str;
-use std::sync::{Arc, Mutex};
 use std::thread;
 
 use syntax::ast;
@@ -168,7 +168,7 @@ pub fn run<F>(run_compiler: F) -> isize
                     handler.emit(&MultiSpan::new(),
                                  "aborting due to previous error(s)",
                                  errors::Level::Fatal);
-                    exit_on_err();
+                    panic::resume_unwind(Box::new(errors::FatalErrorMarker));
                 }
             }
         }
@@ -1228,27 +1228,16 @@ pub fn in_rustc_thread<F, R>(f: F) -> Result<R, Box<Any + Send>>
 /// The diagnostic emitter yielded to the procedure should be used for reporting
 /// errors of the compiler.
 pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
-    struct Sink(Arc<Mutex<Vec<u8>>>);
-    impl Write for Sink {
-        fn write(&mut self, data: &[u8]) -> io::Result<usize> {
-            Write::write(&mut *self.0.lock().unwrap(), data)
-        }
-        fn flush(&mut self) -> io::Result<()> {
-            Ok(())
-        }
-    }
-
-    let data = Arc::new(Mutex::new(Vec::new()));
-    let err = Sink(data.clone());
-
     let result = in_rustc_thread(move || {
-        io::set_panic(Some(box err));
         f()
     });
 
     if let Err(value) = result {
         // Thread panicked without emitting a fatal diagnostic
-        if !value.is::<errors::FatalError>() {
+        if !value.is::<errors::FatalErrorMarker>() {
+            // Emit a newline
+            eprintln!("");
+
             let emitter =
                 Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
                                                                 None,
@@ -1273,22 +1262,12 @@ fn flush(&mut self) -> io::Result<()> {
                              &note,
                              errors::Level::Note);
             }
-
-            eprintln!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
         }
 
-        exit_on_err();
+        panic::resume_unwind(Box::new(errors::FatalErrorMarker));
     }
 }
 
-fn exit_on_err() -> ! {
-    // Panic so the process returns a failure code, but don't pollute the
-    // output with some unnecessary panic messages, we've already
-    // printed everything that we needed to.
-    io::set_panic(Some(box io::sink()));
-    panic!();
-}
-
 #[cfg(stage0)]
 pub fn diagnostics_registry() -> errors::registry::Registry {
     use errors::registry::Registry;
index 1fb673815eea328c1f34955e73ba5f7e27e7d5ae..33948ea92b98ea83de57266a3a9403274c2765bf 100644 (file)
@@ -19,6 +19,7 @@
 #![cfg_attr(unix, feature(libc))]
 #![feature(conservative_impl_trait)]
 #![feature(i128_type)]
+#![feature(optin_builtin_traits)]
 
 extern crate term;
 #[cfg(unix)]
@@ -44,6 +45,7 @@
 use std::{error, fmt};
 use std::sync::atomic::AtomicUsize;
 use std::sync::atomic::Ordering::SeqCst;
+use std::panic;
 
 mod diagnostic;
 mod diagnostic_builder;
@@ -201,6 +203,18 @@ fn push_trailing(buf: &mut String,
 #[must_use]
 pub struct FatalError;
 
+pub struct FatalErrorMarker;
+
+// Don't implement Send on FatalError. This makes it impossible to panic!(FatalError).
+// We don't want to invoke the panic handler and print a backtrace for fatal errors.
+impl !Send for FatalError {}
+
+impl FatalError {
+    pub fn raise(self) -> ! {
+        panic::resume_unwind(Box::new(FatalErrorMarker))
+    }
+}
+
 impl fmt::Display for FatalError {
     fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
         write!(f, "parser fatal error")
@@ -539,7 +553,7 @@ pub fn abort_if_errors(&self) {
             }
         }
 
-        panic!(self.fatal(&s));
+        self.fatal(&s).raise();
     }
     pub fn emit(&self, msp: &MultiSpan, msg: &str, lvl: Level) {
         if lvl == Warning && !self.flags.can_emit_warnings {
index db8db16a6c421d6dfd396ac77ddb0c51122f4a18..8afa63a5e9735e113bceac783870cdca3d54d91f 100644 (file)
@@ -155,7 +155,7 @@ fn get_llvm_opt_size(optimize: config::OptLevel) -> llvm::CodeGenOptSize {
 
 pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
     target_machine_factory(sess)().unwrap_or_else(|err| {
-        panic!(llvm_err(sess.diagnostic(), err))
+        llvm_err(sess.diagnostic(), err).raise()
     })
 }
 
@@ -589,7 +589,7 @@ fn generate_lto_work(cgcx: &CodegenContext,
                  "generate lto")
     }).unwrap_or(Timeline::noop());
     let lto_modules = lto::run(cgcx, modules, &mut timeline)
-        .unwrap_or_else(|e| panic!(e));
+        .unwrap_or_else(|e| e.raise());
 
     lto_modules.into_iter().map(|module| {
         let cost = module.cost();
index 612d8501fb2afcf49f176a357076f6dfa25ea93d..025aa94ce06f5afae48a09ed0c0b1a05f0340f01 100644 (file)
@@ -786,7 +786,7 @@ pub fn struct_span_fatal<S: Into<MultiSpan>>(&self,
     ///   substitute; we never hit resolve/type-checking so the dummy
     ///   value doesn't have to match anything)
     pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
-        panic!(self.parse_sess.span_diagnostic.span_fatal(sp, msg));
+        self.parse_sess.span_diagnostic.span_fatal(sp, msg).raise();
     }
 
     /// Emit `msg` attached to `sp`, without immediately stopping
index 11988a8f89d70a471512a01acf9393cf03ff27ce..44a073545a7302acbe2ce9210af27263850016ab 100644 (file)
@@ -455,7 +455,7 @@ fn expand_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) -> Optio
                 suggested_limit));
             err.emit();
             self.cx.trace_macros_diag();
-            panic!(FatalError);
+            FatalError.raise();
         }
 
         Some(result)
index 6b08448107a9fbc54354bd3d2e904ae0f9109aff..ec4e6ced1b273a9b69e96c689c655436bd316eae 100644 (file)
@@ -116,9 +116,10 @@ fn make_items(mut self: Box<ExpandResult<'a>>)
             while self.p.token != token::Eof {
                 match panictry!(self.p.parse_item()) {
                     Some(item) => ret.push(item),
-                    None => panic!(self.p.diagnostic().span_fatal(self.p.span,
+                    None => self.p.diagnostic().span_fatal(self.p.span,
                                                            &format!("expected item, found `{}`",
-                                                                    self.p.this_token_to_string())))
+                                                                    self.p.this_token_to_string()))
+                                               .raise()
                 }
             }
             Some(ret)
index 124477620c27fea7de75b7c3fbdca7af39c693f8..3e3c1618fffb2de30119d58246fffb69aad263c3 100644 (file)
@@ -573,7 +573,7 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
             Some(i) => token::NtItem(i),
             None => {
                 p.fatal("expected an item keyword").emit();
-                panic!(FatalError);
+                FatalError.raise();
             }
         },
         "block" => token::NtBlock(panictry!(p.parse_block())),
@@ -581,7 +581,7 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
             Some(s) => token::NtStmt(s),
             None => {
                 p.fatal("expected a statement").emit();
-                panic!(FatalError);
+                FatalError.raise();
             }
         },
         "pat" => token::NtPat(panictry!(p.parse_pat())),
@@ -597,7 +597,7 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal {
                 let token_str = pprust::token_to_string(&p.token);
                 p.fatal(&format!("expected ident, found {}",
                                  &token_str[..])).emit();
-                panic!(FatalError)
+                FatalError.raise()
             }
         },
         "path" => token::NtPath(panictry!(p.parse_path_common(PathStyle::Type, false))),
index d86603e94e9df2844dd7af4ec7dd4e9c7f129e08..9efb4faa63535725bc198d261465afe694120063 100644 (file)
@@ -222,10 +222,10 @@ pub fn compile(sess: &ParseSess, features: &RefCell<Features>, def: &ast::Item)
         Success(m) => m,
         Failure(sp, tok) => {
             let s = parse_failure_msg(tok);
-            panic!(sess.span_diagnostic.span_fatal(sp.substitute_dummy(def.span), &s));
+            sess.span_diagnostic.span_fatal(sp.substitute_dummy(def.span), &s).raise();
         }
         Error(sp, s) => {
-            panic!(sess.span_diagnostic.span_fatal(sp.substitute_dummy(def.span), &s));
+            sess.span_diagnostic.span_fatal(sp.substitute_dummy(def.span), &s).raise();
         }
     };
 
index 5a7b53153fd6139ba2672503a61d39067ff57b7f..8512e215ca7655cad4d5bf4cac965867b1e908a9 100644 (file)
@@ -1954,7 +1954,7 @@ fn check(self, handler: &Handler) {
                 .span_note(ca_span, "`#![feature(custom_attribute)]` declared here")
                 .emit();
 
-            panic!(FatalError);
+            FatalError.raise();
         }
 
         if let (Some(span), None) = (self.copy_closures, self.clone_closures) {
@@ -1963,7 +1963,7 @@ fn check(self, handler: &Handler) {
                   .span_note(span, "`#![feature(copy_closures)]` declared here")
                   .emit();
 
-            panic!(FatalError);
+            FatalError.raise();
         }
     }
 }
index d7f7ff554db4bbf6ab64adfaa35e38ea87fdfe0a..3b4c5da10f20b35b5f0014a956419e00b4125d11 100644 (file)
@@ -54,7 +54,7 @@ macro_rules! panictry {
             Ok(e) => e,
             Err(mut e) => {
                 e.emit();
-                panic!(FatalError);
+                FatalError.raise()
             }
         }
     })
index 49362f077992145d08abde3248857ad56786b98d..63aa5d28ce8dc9a6df04454c397886d85f9262da 100644 (file)
@@ -265,7 +265,7 @@ fn read_block_comment(rdr: &mut StringReader,
         while level > 0 {
             debug!("=== block comment level {}", level);
             if rdr.is_eof() {
-                panic!(rdr.fatal("unterminated block comment"));
+                rdr.fatal("unterminated block comment").raise();
             }
             if rdr.ch_is('\n') {
                 trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col);
index 9828995362a35fcadeb4845f065cd770ab2d0f6c..b95c91548d00b99954ed70701f9e1cc87eed12ed 100644 (file)
@@ -90,7 +90,7 @@ fn unwrap_or_abort(&mut self, res: Result<TokenAndSpan, ()>) -> TokenAndSpan {
             Ok(tok) => tok,
             Err(_) => {
                 self.emit_fatal_errors();
-                panic!(FatalError);
+                FatalError.raise();
             }
         }
     }
@@ -191,7 +191,7 @@ pub fn new(sess: &'a ParseSess, filemap: Rc<syntax_pos::FileMap>) -> Self {
         let mut sr = StringReader::new_raw(sess, filemap);
         if sr.advance_token().is_err() {
             sr.emit_fatal_errors();
-            panic!(FatalError);
+            FatalError.raise();
         }
         sr
     }
@@ -216,7 +216,7 @@ pub fn retokenize(sess: &'a ParseSess, mut span: Span) -> Self {
 
         if sr.advance_token().is_err() {
             sr.emit_fatal_errors();
-            panic!(FatalError);
+            FatalError.raise();
         }
         sr
     }
@@ -647,7 +647,7 @@ fn scan_block_comment(&mut self) -> Option<TokenAndSpan> {
                     "unterminated block comment"
                 };
                 let last_bpos = self.pos;
-                panic!(self.fatal_span_(start_bpos, last_bpos, msg));
+                self.fatal_span_(start_bpos, last_bpos, msg).raise();
             }
             let n = self.ch.unwrap();
             match n {
@@ -808,9 +808,9 @@ fn scan_hex_digits(&mut self, n_digits: usize, delim: char, below_0x7f_only: boo
         for _ in 0..n_digits {
             if self.is_eof() {
                 let last_bpos = self.pos;
-                panic!(self.fatal_span_(start_bpos,
-                                        last_bpos,
-                                        "unterminated numeric character escape"));
+                self.fatal_span_(start_bpos,
+                                 last_bpos,
+                                 "unterminated numeric character escape").raise();
             }
             if self.ch_is(delim) {
                 let last_bpos = self.pos;
@@ -1025,9 +1025,9 @@ fn scan_unicode_escape(&mut self, delim: char) -> bool {
                     }
                 },
                 None => {
-                    panic!(self.fatal_span_(start_bpos,
-                                            self.pos,
-                                            "unterminated unicode escape (found EOF)"));
+                    self.fatal_span_(start_bpos,
+                                     self.pos,
+                                     "unterminated unicode escape (found EOF)").raise();
                 }
             }
             self.bump();
@@ -1283,9 +1283,9 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
                     // lifetimes shouldn't end with a single quote
                     // if we find one, then this is an invalid character literal
                     if self.ch_is('\'') {
-                        panic!(self.fatal_span_verbose(
-                               start_with_quote, self.next_pos,
-                               String::from("character literal may only contain one codepoint")));
+                        self.fatal_span_verbose(start_with_quote, self.next_pos,
+                                String::from("character literal may only contain one codepoint"))
+                            .raise();
 
                     }
 
@@ -1332,9 +1332,8 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
                             break;
                         }
                     }
-                    panic!(self.fatal_span_verbose(
-                           start_with_quote, pos,
-                           String::from("character literal may only contain one codepoint")));
+                    self.fatal_span_verbose(start_with_quote, pos,
+                        String::from("character literal may only contain one codepoint")).raise();
                 }
 
                 let id = if valid {
@@ -1364,9 +1363,9 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
                 while !self.ch_is('"') {
                     if self.is_eof() {
                         let last_bpos = self.pos;
-                        panic!(self.fatal_span_(start_bpos,
-                                                last_bpos,
-                                                "unterminated double quote string"));
+                        self.fatal_span_(start_bpos,
+                                         last_bpos,
+                                         "unterminated double quote string").raise();
                     }
 
                     let ch_start = self.pos;
@@ -1399,15 +1398,15 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
 
                 if self.is_eof() {
                     let last_bpos = self.pos;
-                    panic!(self.fatal_span_(start_bpos, last_bpos, "unterminated raw string"));
+                    self.fatal_span_(start_bpos, last_bpos, "unterminated raw string").raise();
                 } else if !self.ch_is('"') {
                     let last_bpos = self.pos;
                     let curr_char = self.ch.unwrap();
-                    panic!(self.fatal_span_char(start_bpos,
-                                                last_bpos,
-                                                "found invalid character; only `#` is allowed \
-                                                 in raw string delimitation",
-                                                curr_char));
+                    self.fatal_span_char(start_bpos,
+                                         last_bpos,
+                                         "found invalid character; only `#` is allowed \
+                                         in raw string delimitation",
+                                         curr_char).raise();
                 }
                 self.bump();
                 let content_start_bpos = self.pos;
@@ -1416,7 +1415,7 @@ fn next_token_inner(&mut self) -> Result<token::Token, ()> {
                 'outer: loop {
                     if self.is_eof() {
                         let last_bpos = self.pos;
-                        panic!(self.fatal_span_(start_bpos, last_bpos, "unterminated raw string"));
+                        self.fatal_span_(start_bpos, last_bpos, "unterminated raw string").raise();
                     }
                     // if self.ch_is('"') {
                     // content_end_bpos = self.pos;
@@ -1573,9 +1572,9 @@ fn scan_byte(&mut self) -> token::Lit {
             // character before position `start` are an
             // ascii single quote and ascii 'b'.
             let pos = self.pos;
-            panic!(self.fatal_span_verbose(start - BytePos(2),
-                                           pos,
-                                           "unterminated byte constant".to_string()));
+            self.fatal_span_verbose(start - BytePos(2),
+                                    pos,
+                                    "unterminated byte constant".to_string()).raise();
         }
 
         let id = if valid {
@@ -1599,7 +1598,7 @@ fn scan_byte_string(&mut self) -> token::Lit {
         while !self.ch_is('"') {
             if self.is_eof() {
                 let pos = self.pos;
-                panic!(self.fatal_span_(start, pos, "unterminated double quote byte string"));
+                self.fatal_span_(start, pos, "unterminated double quote byte string").raise();
             }
 
             let ch_start = self.pos;
@@ -1631,15 +1630,15 @@ fn scan_raw_byte_string(&mut self) -> token::Lit {
 
         if self.is_eof() {
             let pos = self.pos;
-            panic!(self.fatal_span_(start_bpos, pos, "unterminated raw string"));
+            self.fatal_span_(start_bpos, pos, "unterminated raw string").raise();
         } else if !self.ch_is('"') {
             let pos = self.pos;
             let ch = self.ch.unwrap();
-            panic!(self.fatal_span_char(start_bpos,
+            self.fatal_span_char(start_bpos,
                                         pos,
                                         "found invalid character; only `#` is allowed in raw \
                                          string delimitation",
-                                        ch));
+                                        ch).raise();
         }
         self.bump();
         let content_start_bpos = self.pos;
@@ -1648,7 +1647,7 @@ fn scan_raw_byte_string(&mut self) -> token::Lit {
             match self.ch {
                 None => {
                     let pos = self.pos;
-                    panic!(self.fatal_span_(start_bpos, pos, "unterminated raw string"))
+                    self.fatal_span_(start_bpos, pos, "unterminated raw string").raise()
                 }
                 Some('"') => {
                     content_end_bpos = self.pos;
index a9b1e4aaa60068edd658e8b00b5c015d66ceb11e..b671f81c2a84b681c3301d488380a5a0c4e7723f 100644 (file)
@@ -212,8 +212,8 @@ fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
         Err(e) => {
             let msg = format!("couldn't read {:?}: {}", path.display(), e);
             match spanopt {
-                Some(sp) => panic!(sess.span_diagnostic.span_fatal(sp, &msg)),
-                None => panic!(sess.span_diagnostic.fatal(&msg))
+                Some(sp) => sess.span_diagnostic.span_fatal(sp, &msg).raise(),
+                None => sess.span_diagnostic.fatal(&msg).raise()
             }
         }
     }
index eff7dd57f08af0086dc0a2aaee00a3a659b34084..e73550d0719a41cbfe1fe547475b9bbc07f410b7 100644 (file)
@@ -123,7 +123,7 @@ fn fold_item(&mut self, i: P<ast::Item>) -> SmallVector<P<ast::Item>> {
             match i.node {
                 ast::ItemKind::Fn(_, ast::Unsafety::Unsafe, _, _, _, _) => {
                     let diag = self.cx.span_diagnostic;
-                    panic!(diag.span_fatal(i.span, "unsafe functions cannot be used for tests"));
+                    diag.span_fatal(i.span, "unsafe functions cannot be used for tests").raise();
                 }
                 _ => {
                     debug!("this is a test function");
index f375847e705bc636ffe49b05f603c81a30ff8cbc..22e78e9b426b2e7a26544dc7adfc33f5efd42279 100644 (file)
@@ -92,7 +92,7 @@ fn expand(&self,
                 }
 
                 err.emit();
-                panic!(FatalError);
+                FatalError.raise();
             }
         };
 
@@ -103,13 +103,13 @@ fn expand(&self,
                 // fail if there have been errors emitted
                 Ok(_) if ecx.parse_sess.span_diagnostic.err_count() > error_count_before => {
                     ecx.struct_span_fatal(span, msg).emit();
-                    panic!(FatalError);
+                    FatalError.raise();
                 }
                 Ok(new_items) => new_items.into_iter().map(Annotatable::Item).collect(),
                 Err(_) => {
                     // FIXME: handle this better
                     ecx.struct_span_fatal(span, msg).emit();
-                    panic!(FatalError);
+                    FatalError.raise();
                 }
             }
         })
index 5fcedbf50c60f71caeba36d8c8811acab084f204..12400e363f4b0ba477e4bc2596c7b54db132f809 100644 (file)
@@ -51,7 +51,7 @@ fn expand<'cx>(&self,
                 }
 
                 err.emit();
-                panic!(FatalError);
+                FatalError.raise();
             }
         }
     }
@@ -86,7 +86,7 @@ fn expand<'cx>(&self,
                 }
 
                 err.emit();
-                panic!(FatalError);
+                FatalError.raise();
             }
         }
     }