Skip to content

thread 'rustc' panicked at 'assertion failed: !suggestion.is_empty()', compiler/rustc_errors/src/diagnostic.rs:342:9 #91461

Closed
@Badel2

Description

@Badel2

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

Code

#[d=n(_:d:,)]

Error output

error: expected identifier, found reserved identifier `_`
 --> src/lib.rs:1:7
  |
1 | #[d=n(_:d:,)]
  |       ^ expected identifier, found reserved identifier

error: expected type, found `,`
 --> src/lib.rs:1:11
  |
1 | #[d=n(_:d:,)]
  |     -    -^ expected type
  |     |    |
  |     |    tried to parse a type due to this type ascription
  |     while parsing this struct
  |
  = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
  = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information

thread 'rustc' panicked at 'assertion failed: !suggestion.is_empty()', compiler/rustc_errors/src/diagnostic.rs:342:9

Affected versions: I tried nightly 2021-12-01 and stable 1.57 and they both show the same ICE.

Backtrace

   Compiling playground v0.0.1 (/playground)
error: expected identifier, found reserved identifier `_`
 --> src/lib.rs:1:7
  |
1 | #[d=n(_:d:,)]
  |       ^ expected identifier, found reserved identifier

error: expected type, found `,`
 --> src/lib.rs:1:11
  |
1 | #[d=n(_:d:,)]
  |     -    -^ expected type
  |     |    |
  |     |    tried to parse a type due to this type ascription
  |     while parsing this struct
  |
  = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
  = note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information

thread 'rustc' panicked at 'assertion failed: !suggestion.is_empty()', compiler/rustc_errors/src/diagnostic.rs:342:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/48a5999fceeea84a8971634355287faa349909d4/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/48a5999fceeea84a8971634355287faa349909d4/library/core/src/panicking.rs:107:14
   2: core::panicking::panic
             at /rustc/48a5999fceeea84a8971634355287faa349909d4/library/core/src/panicking.rs:48:5
   3: <rustc_errors::diagnostic::Diagnostic>::multipart_suggestion_with_style
   4: <rustc_errors::diagnostic_builder::DiagnosticBuilder>::multipart_suggestion
   5: <rustc_parse::parser::Parser>::collect_tokens_for_expr::<<rustc_parse::parser::Parser>::parse_dot_or_call_expr::{closure#0}>
   6: <rustc_parse::parser::Parser>::parse_prefix_expr
   7: <rustc_parse::parser::Parser>::parse_assoc_expr_with
   8: <rustc_parse::parser::Parser>::collect_tokens_no_attrs::<rustc_ast::ptr::P<rustc_ast::ast::Expr>, <rustc_parse::parser::Parser>::parse_expr_force_collect::{closure#0}>
   9: <rustc_parse::parser::Parser>::parse_attr_item::{closure#0}
  10: <rustc_parse::parser::Parser>::parse_attribute
  11: <rustc_parse::parser::Parser>::parse_outer_attributes
  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::queries::Queries>::parse
  16: <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>>
  17: 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}>
  18: <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.59.0-nightly (48a5999fc 2021-12-01) running on x86_64-unknown-linux-gnu

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

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

Metadata

Metadata

Assignees

Labels

A-frontendArea: Compiler frontend (errors, parsing and HIR)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions