Skip to content

`cargo fmt panics with an Internal Compiler Error (ICE) on rust v1.93 #22704

@alice-i-cecile

Description

@alice-i-cecile

See this CI is job for an example. That will be purged eventually, so full error is stored below.

This is a regression, shipped in Rust 1.93: the PRs triggering this don't appear to share any offensive changes.

Details

$ cargo fmt --all -- --check

thread 'main' (3301) 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(142600), hi: BytePos(142604), ctxt: #0 }], span_labels: [(Span { lo: BytePos(142600), hi: BytePos(142604), ctxt: #0 }, Translated("expected identifier, found keyword"))] }, children: [], suggestions: Enabled([]), args: {"token": Str("Self")}, reserved_args: {}, sort_span: Span { lo: BytePos(142600), hi: BytePos(142604), 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:     0x7ff4744aae73 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hac1d885928ba8582
   1:     0x7ff474c10508 - core::fmt::write::h83ebb4d32483be9e
   2:     0x7ff4760b4cf6 - std::io::Write::write_fmt::ha6a1d6c1ea64b2d0
   3:     0x7ff474478515 - std::panicking::default_hook::{{closure}}::h8e9c4d1276f0925f
   4:     0x7ff474478343 - std::panicking::default_hook::h2b2078d38b534dfb
   5:     0x7ff473506dc7 - std[5414f88c956f4157]::panicking::update_hook::<alloc[cfeb9a527306e1a7]::boxed::Box<rustc_driver_impl[faaaf75c5cd7107d]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7ff474478842 - std::panicking::panic_with_hook::h39b739724e701bfd
   7:     0x7ff4744785d8 - std::panicking::panic_handler::{{closure}}::he540c4833054e458
   8:     0x7ff4744725d9 - std::sys::backtrace::__rust_end_short_backtrace::hfa179d89deec8aed
   9:     0x7ff47445364d - __rustc[d131491b17107b07]::rust_begin_unwind
  10:     0x7ff47172384c - core::panicking::panic_fmt::ha564519d657d9c46
  11:     0x7ff470f21bc2 - core::result::unwrap_failed::h23873bb39ca9a844
  12:     0x7ff47237c818 - <rustc_parse[d45fe68af3813f8d]::parser::Parser>::recover_missing_kw_before_item
  13:     0x7ff4757d885c - <rustc_parse[d45fe68af3813f8d]::parser::Parser>::parse_item_kind
  14:     0x7ff4757d7efe - <rustc_parse[d45fe68af3813f8d]::parser::Parser>::parse_item_kind
  15:     0x7ff4757d381a - <rustc_parse[d45fe68af3813f8d]::parser::Parser>::parse_item_common
  16:     0x7ff4757d342b - <rustc_parse[d45fe68af3813f8d]::parser::Parser>::parse_item
  17:     0x55f53a4e22a8 - rustfmt_nightly[e3626b5415e47b8b]::parse::macros::parse_macro_arg
  18:     0x55f53a4c8ed5 - rustfmt_nightly[e3626b5415e47b8b]::macros::rewrite_macro
  19:     0x55f53a4a5500 - rustfmt_nightly[e3626b5415e47b8b]::expr::format_expr
  20:     0x55f53a3e9908 - <rustfmt_nightly[e3626b5415e47b8b]::overflow::OverflowableItem>::map::<<rustfmt_nightly[e3626b5415e47b8b]::overflow::OverflowableItem as rustfmt_nightly[e3626b5415e47b8b]::rewrite::Rewrite>::rewrite::{closure#0}, core[fcada436b717a91e]::option::Option<alloc[cfeb9a527306e1a7]::string::String>>
  21:     0x55f53a463500 - <rustfmt_nightly[e3626b5415e47b8b]::overflow::Context>::rewrite
  22:     0x55f53a3f012c - rustfmt_nightly[e3626b5415e47b8b]::expr::rewrite_tuple::<alloc[cfeb9a527306e1a7]::boxed::Box<rustc_ast[4080c9cbcd2fbdf3]::ast::Expr>, core[fcada436b717a91e]::slice::iter::Iter<alloc[cfeb9a527306e1a7]::boxed::Box<rustc_ast[4080c9cbcd2fbdf3]::ast::Expr>>>
  23:     0x55f53a4a5674 - rustfmt_nightly[e3626b5415e47b8b]::expr::format_expr
  24:     0x55f53a4afd18 - rustfmt_nightly[e3626b5415e47b8b]::stmt::format_stmt
  25:     0x55f53a452260 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  26:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  27:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  28:     0x55f53a455291 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::visit_block
  29:     0x55f53a4ae97d - rustfmt_nightly[e3626b5415e47b8b]::expr::rewrite_block_with_visitor
  30:     0x55f53a4fe0ff - <rustfmt_nightly[e3626b5415e47b8b]::expr::ControlFlow as rustfmt_nightly[e3626b5415e47b8b]::rewrite::Rewrite>::rewrite_result
  31:     0x55f53a4a6856 - rustfmt_nightly[e3626b5415e47b8b]::expr::format_expr
  32:     0x55f53a3f0f38 - rustfmt_nightly[e3626b5415e47b8b]::expr::rewrite_assign_rhs_expr::<rustc_ast[4080c9cbcd2fbdf3]::ast::Expr>
  33:     0x55f53a3f37c9 - rustfmt_nightly[e3626b5415e47b8b]::expr::rewrite_assign_rhs_with::<alloc[cfeb9a527306e1a7]::string::String, rustc_ast[4080c9cbcd2fbdf3]::ast::Expr>
  34:     0x55f53a4e4787 - <rustc_ast[4080c9cbcd2fbdf3]::ast::Local as rustfmt_nightly[e3626b5415e47b8b]::rewrite::Rewrite>::rewrite_result
  35:     0x55f53a4afddd - rustfmt_nightly[e3626b5415e47b8b]::stmt::format_stmt
  36:     0x55f53a452260 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  37:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  38:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  39:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  40:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  41:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  42:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  43:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  44:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  45:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  46:     0x55f53a455291 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::visit_block
  21:     0x55f53a463500 - <rustfmt_nightly[e3626b5415e47b8b]::overflow::Context>::rewrite
  22:     0x55f53a3f012c - rustfmt_nightly[e3626b5415e47b8b]::expr::rewrite_tuple::<alloc[cfeb9a527306e1a7]::boxed::Box<rustc_ast[4080c9cbcd2fbdf3]::ast::Expr>, core[fcada436b717a91e]::slice::iter::Iter<alloc[cfeb9a527306e1a7]::boxed::Box<rustc_ast[4080c9cbcd2fbdf3]::ast::Expr>>>
  23:     0x55f53a4a5674 - rustfmt_nightly[e3626b5415e47b8b]::expr::format_expr
  24:     0x55f53a4afd18 - rustfmt_nightly[e3626b5415e47b8b]::stmt::format_stmt
  25:     0x55f53a452260 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  26:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  27:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  28:     0x55f53a455291 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::visit_block
  29:     0x55f53a4ae97d - rustfmt_nightly[e3626b5415e47b8b]::expr::rewrite_block_with_visitor
  30:     0x55f53a4fe0ff - <rustfmt_nightly[e3626b5415e47b8b]::expr::ControlFlow as rustfmt_nightly[e3626b5415e47b8b]::rewrite::Rewrite>::rewrite_result
  31:     0x55f53a4a6856 - rustfmt_nightly[e3626b5415e47b8b]::expr::format_expr
  32:     0x55f53a3f110c - rustfmt_nightly[e3626b5415e47b8b]::expr::rewrite_assign_rhs_expr::<rustc_ast[4080c9cbcd2fbdf3]::ast::Expr>
  33:     0x55f53a3f37c9 - rustfmt_nightly[e3626b5415e47b8b]::expr::rewrite_assign_rhs_with::<alloc[cfeb9a527306e1a7]::string::String, rustc_ast[4080c9cbcd2fbdf3]::ast::Expr>
  34:     0x55f53a4e4787 - <rustc_ast[4080c9cbcd2fbdf3]::ast::Local as rustfmt_nightly[e3626b5415e47b8b]::rewrite::Rewrite>::rewrite_result
  35:     0x55f53a4afddd - rustfmt_nightly[e3626b5415e47b8b]::stmt::format_stmt
  36:     0x55f53a452260 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  37:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  38:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  39:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  40:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  41:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  42:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  43:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  44:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  45:     0x55f53a4527cb - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_stmts
  46:     0x55f53a455291 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::visit_block
  47:     0x55f53a457153 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::visit_fn
  48:     0x55f53a4511d0 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::visit_item
  49:     0x55f53a4991a3 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::visit_items_with_reordering
  50:     0x55f53a455c40 - <rustfmt_nightly[e3626b5415e47b8b]::visitor::FmtVisitor>::walk_mod_items
  51:     0x55f53a3d41f7 - <rustfmt_nightly[e3626b5415e47b8b]::Session<std[5414f88c956f4157]::io::stdio::Stdout>>::format_input_inner::{closure#0}
  52:     0x55f53a3c5a27 - rustfmt[5961037fcd190603]::format_and_emit_report::<std[5414f88c956f4157]::io::stdio::Stdout>
  53:     0x55f53a3d9767 - rustfmt[5961037fcd190603]::execute
  54:     0x55f53a3d5f60 - rustfmt[5961037fcd190603]::main
  55:     0x55f53a3d0d23 - std[5414f88c956f4157]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  56:     0x55f53a3d1409 - std[5414f88c956f4157]::rt::lang_start::<()>::{closure#0}
  57:     0x7ff475d5ba66 - std::rt::lang_start_internal::h74b643a2cc7fe3b4
  58:     0x55f53a3e4cf8 - main
  59:     0x7ff46f62a1ca - <unknown>
  60:     0x7ff46f62a28b - __libc_start_main
  61:     0x55f53a2c8b49 - <unknown>
  62:                0x0 - <unknown>

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

note: we would appreciate a bug report: https://github.com/rust-lang/rustfmt/issues/new?labels=bug

note: rustc 1.93.0 (254b59607 2026-01-19) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
Diff in /home/runner/work/bevy/bevy/crates/bevy_render/src/camera.rs:41:
 };
 use bevy_image::Image;
 use bevy_log::warn;
+use bevy_log::warn_once;
 use bevy_math::{uvec2, vec2, Mat4, URect, UVec2, UVec4, Vec2};
 use bevy_platform::collections::{HashMap, HashSet};
 use bevy_reflect::prelude::*;
Diff in /home/runner/work/bevy/bevy/crates/bevy_render/src/camera.rs:47:
 use bevy_transform::components::GlobalTransform;
 use bevy_window::{PrimaryWindow, Window, WindowCreated, WindowResized, WindowScaleFactorChanged};
-use bevy_log::warn_once;
 use wgpu::TextureFormat;
 
 #[derive(Default)]

thread 'main' (2974) panicked at tools/ci/src/ci.rs:62:13:
One or more CI commands failed:
format: Please run 'cargo fmt --all' to format your code.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Process completed with exit code 101.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Build-SystemRelated to build systems or continuous integrationC-BugAn unexpected or incorrect behaviorS-BlockedThis cannot move forward until something else changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions