Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit dropped unemitted errors to aid in ICE debugging #62605

Merged
merged 1 commit into from
Jul 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/librustc_errors/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,13 @@ impl<'a> Debug for DiagnosticBuilder<'a> {
impl<'a> Drop for DiagnosticBuilder<'a> {
fn drop(&mut self) {
if !panicking() && !self.cancelled() {
let mut db = DiagnosticBuilder::new(self.handler,
Level::Bug,
"Error constructed but not emitted");
let mut db = DiagnosticBuilder::new(
self.handler,
Level::Bug,
"the following error was constructed but not emitted",
);
db.emit();
self.emit();
panic!();
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6666,12 +6666,13 @@ impl<'a> Parser<'a> {
}

/// Reads a module from a source file.
fn eval_src_mod(&mut self,
path: PathBuf,
directory_ownership: DirectoryOwnership,
name: String,
id_sp: Span)
-> PResult<'a, (ast::Mod, Vec<Attribute> )> {
fn eval_src_mod(
&mut self,
path: PathBuf,
directory_ownership: DirectoryOwnership,
name: String,
id_sp: Span,
) -> PResult<'a, (ast::Mod, Vec<Attribute>)> {
let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut();
if let Some(i) = included_mod_stack.iter().position(|p| *p == path) {
let mut err = String::from("circular modules: ");
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/util/parser_testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ fn with_error_checking_parse<'a, T, F>(s: String, ps: &'a ParseSess, f: F) -> T
}

/// Parse a string, return a crate.
pub fn string_to_crate (source_str : String) -> ast::Crate {
pub fn string_to_crate(source_str : String) -> ast::Crate {
let ps = ParseSess::new(FilePathMapping::empty());
with_error_checking_parse(source_str, &ps, |p| {
p.parse_crate_mod()
})
}

/// Parse a string, return an expr
pub fn string_to_expr (source_str : String) -> P<ast::Expr> {
pub fn string_to_expr(source_str : String) -> P<ast::Expr> {
let ps = ParseSess::new(FilePathMapping::empty());
with_error_checking_parse(source_str, &ps, |p| {
p.parse_expr()
})
}

/// Parse a string, return an item
pub fn string_to_item (source_str : String) -> Option<P<ast::Item>> {
pub fn string_to_item(source_str : String) -> Option<P<ast::Item>> {
let ps = ParseSess::new(FilePathMapping::empty());
with_error_checking_parse(source_str, &ps, |p| {
p.parse_item()
Expand Down