Closed
Description
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
:
rust/compiler/rustc_parse/src/parser/pat.rs
Line 820 in c9c4b5d