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

ICE: panicked at 'explicit panic', compiler/rustc_errors/src/diagnostic_builder.rs:424:13 #85794

Closed
chengniansun opened this issue May 28, 2021 · 2 comments · Fixed by #85818
Closed
Assignees
Labels
A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

Code

struct Baz {
  inner : dyn fn ()
}

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (1c6868aa2 2021-05-27)
binary: rustc
commit-hash: 1c6868aa21981b37cbd3fc95828ee3b0ac22d494
commit-date: 2021-05-27
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1

Error output

error: expected `,`, or `}`, found keyword `fn`
 --> mutant.rs:2:14
  |
2 |   inner : dyn fn ()
  |              ^ help: try adding a comma: `,`

error: internal compiler error: the following error was constructed but not emitted

error: expected identifier, found `(`
 --> mutant.rs:2:18
  |
2 |   inner : dyn fn ()
  |                  ^ expected identifier

thread 'rustc' panicked at 'explicit panic', compiler/rustc_errors/src/diagnostic_builder.rs:424:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (1c6868aa2 2021-05-27) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 3 previous errors
Backtrace

error: expected `,`, or `}`, found keyword `fn`
 --> mutant.rs:2:14
  |
2 |   inner : dyn fn ()
  |              ^ help: try adding a comma: `,`

error: internal compiler error: the following error was constructed but not emitted

error: expected identifier, found `(`
 --> mutant.rs:2:18
  |
2 |   inner : dyn fn ()
  |                  ^ expected identifier

thread 'rustc' panicked at 'explicit panic', compiler/rustc_errors/src/diagnostic_builder.rs:424:13
stack backtrace:
   0: std::panicking::begin_panic
   1: <rustc_errors::diagnostic_builder::DiagnosticBuilder as core::ops::drop::Drop>::drop
   2: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_field_ident
   3: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_field_def::{{closure}}
   4: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_record_struct_body
   5: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item_kind
   6: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item_common
   7: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_mod
   8: rustc_parse::parse_crate_from_file
   9: rustc_session::utils::<impl rustc_session::session::Session>::time
  10: rustc_interface::queries::Queries::parse
  11: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-nightly (1c6868aa2 2021-05-27) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to 3 previous errors

@chengniansun chengniansun added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 28, 2021
@LingMan
Copy link
Contributor

LingMan commented May 29, 2021

This regressed in #85057, which is a rollup. Luckily #76808 is the only real candidate though.

The panic that gets called is this one:

let mut db = DiagnosticBuilder::new(
self.0.handler,
Level::Bug,
"the following error was constructed but not emitted",
);
db.emit();
self.emit();
panic!();

From a quick scan of #76808 a result gets dropped here :

let _ = self.parse_fn(&mut Vec::new(), |_| true, lo);

cc @LeSeulArtichaut

searched nightlies: from nightly-2021-05-07 to nightly-2021-05-29
regressed nightly: nightly-2021-05-09
searched commits: from 770792f to 881c1ac
regressed commit: abf3ec5

bisected with cargo-bisect-rustc v0.6.0

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --prompt 

@LeSeulArtichaut
Copy link
Contributor

Mhh, I don't even remember why I added this call to parse_fn in the first place, maybe to consume the fn body and get fewer/cleaner errors? Should have added a comment...
Anyway fixing this should be easy, we can delay_as_bug (or cancel) the error, or remove the call to parse_fn.

@LeSeulArtichaut LeSeulArtichaut added A-parser Area: The parsing of Rust source code to an AST E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels May 29, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 29, 2021
@LeSeulArtichaut LeSeulArtichaut self-assigned this May 29, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 30, 2021
…, r=petrochenkov

Don't drop `PResult` without handling the error

Fixes rust-lang#85794.
@bors bors closed this as completed in 71a7f8f May 30, 2021
@LeSeulArtichaut LeSeulArtichaut removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants