diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2016-03-25 18:17:04 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2016-03-30 22:23:48 +0200 |
| commit | 2646663b5a9b9bd021e58eb9cd8bcc63b7925c95 (patch) | |
| tree | 072fa5018fa118c757a57653d74750f1fed56b8c /src/libsyntax/errors | |
| parent | 40deb279a87e640f799140e9f19b3e64623c30da (diff) | |
| download | rust-2646663b5a9b9bd021e58eb9cd8bcc63b7925c95.tar.gz rust-2646663b5a9b9bd021e58eb9cd8bcc63b7925c95.zip | |
Put in `-Z continue-parse-after-error`
This works by adding a boolean flag, `continue_after_error`, to `syntax::errors::Handler` that can be imperatively set to `true` or `false` via a new `fn set_continue_after_error`. The flag starts off true (since we generally try to recover from compiler errors, and `Handler` is shared across all phases). Then, during the `phase_1_parse_input`, we consult the setting of the `-Z continue-parse-after-error` debug flag to determine whether we should leave the flag set to `true` or should change it to `false`. ---- (We might consider adding a debugflag to do such aborts in other places where we are currently attempting recovery, such as resolve, but I think the parser is the really important case to handle in the face of #31994 and the parser bugs of varying degrees that were injected by parse error recovery.)
Diffstat (limited to 'src/libsyntax/errors')
| -rw-r--r-- | src/libsyntax/errors/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax/errors/mod.rs b/src/libsyntax/errors/mod.rs index 9e1cb60f54f..c8c12d5a883 100644 --- a/src/libsyntax/errors/mod.rs +++ b/src/libsyntax/errors/mod.rs @@ -370,6 +370,7 @@ pub struct Handler { emit: RefCell<Box<Emitter>>, pub can_emit_warnings: bool, treat_err_as_bug: bool, + continue_after_error: Cell<bool>, delayed_span_bug: RefCell<Option<(MultiSpan, String)>>, } @@ -392,10 +393,15 @@ impl Handler { emit: RefCell::new(e), can_emit_warnings: can_emit_warnings, treat_err_as_bug: treat_err_as_bug, + continue_after_error: Cell::new(true), delayed_span_bug: RefCell::new(None), } } + pub fn set_continue_after_error(&self, continue_after_error: bool) { + self.continue_after_error.set(continue_after_error); + } + pub fn struct_dummy<'a>(&'a self) -> DiagnosticBuilder<'a> { DiagnosticBuilder::new(&self.emit, Level::Cancelled, "") } @@ -612,6 +618,7 @@ impl Handler { lvl: Level) { if lvl == Warning && !self.can_emit_warnings { return } self.emit.borrow_mut().emit(msp, msg, None, lvl); + if !self.continue_after_error.get() { self.abort_if_errors(); } } pub fn emit_with_code(&self, msp: Option<&MultiSpan>, @@ -620,10 +627,12 @@ impl Handler { lvl: Level) { if lvl == Warning && !self.can_emit_warnings { return } self.emit.borrow_mut().emit(msp, msg, Some(code), lvl); + if !self.continue_after_error.get() { self.abort_if_errors(); } } pub fn custom_emit(&self, rsp: RenderSpan, msg: &str, lvl: Level) { if lvl == Warning && !self.can_emit_warnings { return } self.emit.borrow_mut().custom_emit(&rsp, msg, lvl); + if !self.continue_after_error.get() { self.abort_if_errors(); } } } |
