Skip to content

rustc 1.193.0-beta.1 panic during formatting #6749

@bd-g

Description

@bd-g

When running cargo fmt with rustc 1.193.0-beta.2 on a proprietary codebase, I get a compiler panic.

  • The Rust project in question has a git submodule that is registered as a dependency in the Cargo.toml file with {path = ./local/path}
  • That dependencies is using Rust Edition 2021, whereas the parent Rust project is using Rust Edition 2024
  • The git submodule dependency is only imported into a single file.
  • When I run cargo fmt with stable 1.192.0, that single file is re-formatted from R.E. 2021 rules to R.E. 2024 rules.
  • However, when I run cargo fmt with 1.193.0-beta.2, I get a compiler panic as displayed below.
rustc version Panics?
1.192.0 No
1.193.0-beta.1 Yes
1.193.0-beta.2 Yes
1.194.0-nightly Yes

Compiler output from 1.193.0-beta.1 panic

note: rustc 1.93.0-beta.1 (1b6e21e16 2025-12-08) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

thread 'main' (998423) panicked at compiler/rustc_parse/src/parser/item.rs:400:32:
called `Result::unwrap()` on an `Err` value: Some(DiagInner { level: Error, messages: [(FluentIdentifier("parse_expected_identifier_found_keyword_str", None), NoStyle)], code: None, lint_id: None, span: MultiSpan { primary_spans: [Span { lo: BytePos(15900), hi: BytePos(15904), ctxt: #0 }], span_labels: [(Span { lo: BytePos(15900), hi: BytePos(15904), ctxt: #0 }, Translated("expected identifier, found keyword"))] }, children: [], suggestions: Enabled([]), args: {"token": Str("Self")}, reserved_args: {}, sort_span: Span { lo: BytePos(15900), hi: BytePos(15904), ctxt: #0 }, is_lint: None, long_ty_path: None, emitted_at: DiagLocation { file: "compiler/rustc_parse/src/parser/diagnostics.rs", line: 381, col: 34 } })
stack backtrace:
   0:     0x7ff3f9491eb3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h56dc325676d2f229
   1:     0x7ff3f9c10f08 - core::fmt::write::h1296211c79dcfe4d
   2:     0x7ff3fb0c23b6 - std::io::Write::write_fmt::h09c87e2e897f7f51
   3:     0x7ff3f945f6b5 - std::panicking::default_hook::{{closure}}::h60fe637000259840
   4:     0x7ff3f945f4e3 - std::panicking::default_hook::h62b896381ecee5ff
   5:     0x7ff3f84ea7b7 - std[5426fc87474ba969]::panicking::update_hook::<alloc[feab500cd1938842]::boxed::Box<rustc_driver_impl[c9d56e6b8d2b2f02]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7ff3f945f9e2 - std::panicking::panic_with_hook::h148eda47c092496f
   7:     0x7ff3f945f778 - std::panicking::panic_handler::{{closure}}::ha3c322b8140a1a72
   8:     0x7ff3f9459789 - std::sys::backtrace::__rust_end_short_backtrace::h3f9e1abc6ce6b66f
   9:     0x7ff3f943a97d - __rustc[1cd308e5081fab86]::rust_begin_unwind
  10:     0x7ff3f69e22bc - core::panicking::panic_fmt::hc375fcb7f9c166b1
  11:     0x7ff3f5e978b2 - core::result::unwrap_failed::h74dec87b3f9885a4
  12:     0x7ff3f7278bf8 - <rustc_parse[58503836e5d1806d]::parser::Parser>::recover_missing_kw_before_item
  13:     0x7ff3fa97245c - <rustc_parse[58503836e5d1806d]::parser::Parser>::parse_item_kind
  14:     0x7ff3fa971afe - <rustc_parse[58503836e5d1806d]::parser::Parser>::parse_item_kind
  15:     0x7ff3fa96d41a - <rustc_parse[58503836e5d1806d]::parser::Parser>::parse_item_common
  16:     0x7ff3fa96d02b - <rustc_parse[58503836e5d1806d]::parser::Parser>::parse_item
  17:     0x562de4d449e8 - rustfmt_nightly[1022aa65d2434ee0]::parse::macros::parse_macro_arg
  18:     0x562de4d2b4a5 - rustfmt_nightly[1022aa65d2434ee0]::macros::rewrite_macro
  19:     0x562de4d079e3 - rustfmt_nightly[1022aa65d2434ee0]::expr::format_expr
  20:     0x562de4c515c8 - rustfmt_nightly[1022aa65d2434ee0]::expr::rewrite_assign_rhs_expr::<rustc_ast[87cc9e514bfc5189]::ast::Expr>
  21:     0x562de4c53e59 - rustfmt_nightly[1022aa65d2434ee0]::expr::rewrite_assign_rhs_with::<alloc[feab500cd1938842]::string::String, rustc_ast[87cc9e514bfc5189]::ast::Expr>
  22:     0x562de4d465b7 - <rustc_ast[87cc9e514bfc5189]::ast::Local as rustfmt_nightly[1022aa65d2434ee0]::rewrite::Rewrite>::rewrite_result
  23:     0x562de4d122bd - rustfmt_nightly[1022aa65d2434ee0]::stmt::format_stmt
  24:     0x562de4cb42b0 - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  25:     0x562de4cb72e1 - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::visit_block
  26:     0x562de4d10e5d - rustfmt_nightly[1022aa65d2434ee0]::expr::rewrite_block_with_visitor
  27:     0x562de4d0fb11 - rustfmt_nightly[1022aa65d2434ee0]::expr::rewrite_block_inner
  28:     0x562de4d08909 - rustfmt_nightly[1022aa65d2434ee0]::expr::format_expr
  29:     0x562de4c5179c - rustfmt_nightly[1022aa65d2434ee0]::expr::rewrite_assign_rhs_expr::<rustc_ast[87cc9e514bfc5189]::ast::Expr>
  30:     0x562de4c53e59 - rustfmt_nightly[1022aa65d2434ee0]::expr::rewrite_assign_rhs_with::<alloc[feab500cd1938842]::string::String, rustc_ast[87cc9e514bfc5189]::ast::Expr>
  31:     0x562de4d465b7 - <rustc_ast[87cc9e514bfc5189]::ast::Local as rustfmt_nightly[1022aa65d2434ee0]::rewrite::Rewrite>::rewrite_result
  32:     0x562de4d122bd - rustfmt_nightly[1022aa65d2434ee0]::stmt::format_stmt
  33:     0x562de4cb42b0 - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  34:     0x562de4cb481b - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  35:     0x562de4cb481b - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  36:     0x562de4cb481b - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  37:     0x562de4cb481b - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  38:     0x562de4cb481b - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  39:     0x562de4cb481b - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  40:     0x562de4cb481b - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  41:     0x562de4cb481b - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_stmts
  42:     0x562de4cb72e1 - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::visit_block
  43:     0x562de4cb9193 - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::visit_fn
  44:     0x562de4cb3220 - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::visit_item
  45:     0x562de4cfb3e3 - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::visit_items_with_reordering
  46:     0x562de4cb7c90 - <rustfmt_nightly[1022aa65d2434ee0]::visitor::FmtVisitor>::walk_mod_items
  47:     0x562de4c36817 - <rustfmt_nightly[1022aa65d2434ee0]::Session<std[5426fc87474ba969]::io::stdio::Stdout>>::format_input_inner::{closure#0}
  48:     0x562de4c27fa7 - rustfmt[a4f69f47555bc08c]::format_and_emit_report::<std[5426fc87474ba969]::io::stdio::Stdout>
  49:     0x562de4c3bd80 - rustfmt[a4f69f47555bc08c]::execute
  50:     0x562de4c38580 - rustfmt[a4f69f47555bc08c]::main
  51:     0x562de4c33343 - std[5426fc87474ba969]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  52:     0x562de4c33a29 - std[5426fc87474ba969]::rt::lang_start::<()>::{closure#0}
  53:     0x7ff3fad393e6 - std::rt::lang_start_internal::hafbfc87787530005
  54:     0x562de4c47388 - main
  55:     0x7ff3f462a47e - __libc_start_call_main
  56:     0x7ff3f462a539 - __libc_start_main_alias_1
  57:     0x562de4b2aed9 - <unknown>
  58:                0x0 - <unknown>

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: parserS-needs-reproStatus: this issue has no reproduction and needs a reproduction to make progress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions