Skip to content

Commit d709e8d

Browse files
authored
Rollup merge of #62605 - estebank:emit-dropped-err, r=pnkfelix
Emit dropped unemitted errors to aid in ICE debugging
2 parents d69e958 + c9f7a3d commit d709e8d

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/librustc_errors/diagnostic_builder.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,13 @@ impl<'a> Debug for DiagnosticBuilder<'a> {
380380
impl<'a> Drop for DiagnosticBuilder<'a> {
381381
fn drop(&mut self) {
382382
if !panicking() && !self.cancelled() {
383-
let mut db = DiagnosticBuilder::new(self.handler,
384-
Level::Bug,
385-
"Error constructed but not emitted");
383+
let mut db = DiagnosticBuilder::new(
384+
self.handler,
385+
Level::Bug,
386+
"the following error was constructed but not emitted",
387+
);
386388
db.emit();
389+
self.emit();
387390
panic!();
388391
}
389392
}

src/libsyntax/parse/parser.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -6666,12 +6666,13 @@ impl<'a> Parser<'a> {
66666666
}
66676667

66686668
/// Reads a module from a source file.
6669-
fn eval_src_mod(&mut self,
6670-
path: PathBuf,
6671-
directory_ownership: DirectoryOwnership,
6672-
name: String,
6673-
id_sp: Span)
6674-
-> PResult<'a, (ast::Mod, Vec<Attribute> )> {
6669+
fn eval_src_mod(
6670+
&mut self,
6671+
path: PathBuf,
6672+
directory_ownership: DirectoryOwnership,
6673+
name: String,
6674+
id_sp: Span,
6675+
) -> PResult<'a, (ast::Mod, Vec<Attribute>)> {
66756676
let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut();
66766677
if let Some(i) = included_mod_stack.iter().position(|p| *p == path) {
66776678
let mut err = String::from("circular modules: ");

src/libsyntax/util/parser_testing.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ fn with_error_checking_parse<'a, T, F>(s: String, ps: &'a ParseSess, f: F) -> T
3434
}
3535

3636
/// Parse a string, return a crate.
37-
pub fn string_to_crate (source_str : String) -> ast::Crate {
37+
pub fn string_to_crate(source_str : String) -> ast::Crate {
3838
let ps = ParseSess::new(FilePathMapping::empty());
3939
with_error_checking_parse(source_str, &ps, |p| {
4040
p.parse_crate_mod()
4141
})
4242
}
4343

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

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

0 commit comments

Comments
 (0)