Skip to content

internal compiler error: the following error was constructed but not emitted: unexpected token: . #90993

New issue

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

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

Already on GitHub? # to your account

Closed
Badel2 opened this issue Nov 17, 2021 · 1 comment · Fixed by #90994
Assignees
Labels
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.

Comments

@Badel2
Copy link
Contributor

Badel2 commented Nov 17, 2021

I'm seeing an internal compiler error on the following input, found by fuzz-rustc:

Code

fn main(){
    ...=.
}

Error output

error: unexpected token: `...`
 --> src/main.rs:2:5
  |
2 |     ...=.
  |     ^^^
  |
help: use `..` for an exclusive range
  |
2 |     ..=.
  |     ~~
help: or `..=` for an inclusive range
  |
2 |     ..==.
  |     ~~~

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

error: unexpected token: `.`
 --> src/main.rs:2:9
  |
2 |     ...=.
  |         ^

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

Affected versions: I tried stable 1.56.1 and nightly 2021-11-16

Backtrace

   Compiling playground v0.0.1 (/playground)
error: unexpected token: `...`
 --> src/main.rs:2:5
  |
2 |     ...=.
  |     ^^^
  |
help: use `..` for an exclusive range
  |
2 |     ..=.
  |     ~~
help: or `..=` for an inclusive range
  |
2 |     ..==.
  |     ~~~

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

error: unexpected token: `.`
 --> src/main.rs:2:9
  |
2 |     ...=.
  |         ^

thread 'rustc' panicked at 'explicit panic', compiler/rustc_errors/src/diagnostic_builder.rs:453:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d914f17ca71a33a89b2dc3436fca51b1a091559e/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/d914f17ca71a33a89b2dc3436fca51b1a091559e/library/core/src/panicking.rs:106:14
   2: core::panicking::panic
             at /rustc/d914f17ca71a33a89b2dc3436fca51b1a091559e/library/core/src/panicking.rs:47:5
   3: <rustc_errors::diagnostic_builder::DiagnosticBuilder as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place::<rustc_errors::diagnostic_builder::DiagnosticBuilder>
   5: <rustc_parse::parser::Parser>::inclusive_range_with_incorrect_end
   6: <rustc_parse::parser::Parser>::collect_tokens_for_expr::<<rustc_parse::parser::Parser>::parse_prefix_range_expr::{closure#0}>::{closure#0}
   7: <rustc_parse::parser::Parser>::parse_assoc_expr_with
   8: <rustc_parse::parser::Parser>::parse_stmt_without_recovery
   9: <rustc_parse::parser::Parser>::parse_block_tail
  10: <rustc_parse::parser::Parser>::parse_fn_body
  11: <rustc_parse::parser::Parser>::parse_item_common
  12: <rustc_parse::parser::Parser>::parse_mod
  13: rustc_parse::parse_crate_from_file
  14: <rustc_session::session::Session>::time::<core::result::Result<rustc_ast::ast::Crate, rustc_errors::diagnostic_builder::DiagnosticBuilder>, rustc_interface::passes::parse::{closure#0}>
  15: rustc_interface::passes::parse
  16: <rustc_interface::queries::Queries>::parse
  17: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  18: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  19: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>
  20: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
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.58.0-nightly (d914f17ca 2021-11-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `playground` due to 2 previous errors

I already found a solution, this line is missing e.cancel() before dropping the error returned by parse_pat_range_end:

let _ = self.parse_pat_range_end();

@Badel2 Badel2 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 Nov 17, 2021
@Badel2
Copy link
Contributor Author

Badel2 commented Nov 17, 2021

@rustbot claim

Badel2 added a commit to Badel2/rust that referenced this issue Nov 20, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 20, 2021
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#89741 (Mark `Arc::from_inner` / `Rc::from_inner` as unsafe)
 - rust-lang#90927 (Fix float ICE)
 - rust-lang#90994 (Fix ICE `rust-lang#90993`: add missing call to cancel)
 - rust-lang#91018 (Adopt let_else in more places in rustc_mir_build)
 - rust-lang#91022 (Suggest `await` in more situations where infer types are involved)
 - rust-lang#91088 (Revert "require full validity when determining the discriminant of a value")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 3d4f3ee Nov 21, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant