Skip to content

ICE: None in pretty printing self.print_ident(field.ident.unwrap());  #140333

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn bar() -> impl Into<
    [u8; {
        f_t(&*s);

        c(&*s);

        c(&*s);

        struct AA {
            span: Span,
            #[bar("...")]
            bar: String,
        }

        c1(*x);
    }],
> {
    [99]
}

original:

fn bar() -> impl Into<
    [u8; {
        f_t(&*s);

        c(&*s);

        c(&*s);

        struct AA {
    #[primary_span]
    span: Span,
    #[bar("...")]
    //~^ ERROR `#[bar(...)]` is not a valid attribute
    //~^^ ERROR cannot find attribute `bar` in this scope
    bar: String,
}

        c1(*x);
        let _ = for<'a, 'b> |x: &'a &'a Vec<&'b u32>, b: bool| -> &'a Vec<&'b u32> { *x };
    }],
> {
    [99]
}

Version information

rustc 1.88.0-nightly (5ae50d3b2 2025-04-26)
binary: rustc
commit-hash: 5ae50d3b2182f81eea4e4d90e8da3653547215b5
commit-date: 2025-04-26
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Possibly related line of code:

for field in fields {
self.hardbreak_if_not_bol();
self.maybe_print_comment(field.span.lo());
self.print_outer_attributes(&field.attrs);
self.print_visibility(&field.vis);
self.print_ident(field.ident.unwrap());
self.word_nbsp(":");
self.print_type(&field.ty);
self.word(",");
}
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output


thread 'rustc' panicked at compiler/rustc_ast_pretty/src/pprust/state/item.rs:498:46:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7181c0cf15f3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h86170db8a5b3fc49
   1:     0x7181c1405ac7 - core::fmt::write::ha1bb156c58f196a3
   2:     0x7181c28323d1 - std::io::Write::write_fmt::hbbbf825c1735ebc2
   3:     0x7181c0cf1452 - std::sys::backtrace::BacktraceLock::print::h2bc48979fae37ddc
   4:     0x7181c0cf529a - std::panicking::default_hook::{{closure}}::h430bd6f9c1e510d4
   5:     0x7181c0cf4e1f - std::panicking::default_hook::hae56df55a51fb242
   6:     0x7181bfd76873 - std[1f110c8b716c47e7]::panicking::update_hook::<alloc[822929b315a5930e]::boxed::Box<rustc_driver_impl[3d6f1070604d0a13]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7181c0cf5b13 - std::panicking::rust_panic_with_hook::hf9bc844a070983e0
   8:     0x7181c0cf57d6 - std::panicking::begin_panic_handler::{{closure}}::h2b959916b538107b
   9:     0x7181c0cf1ac9 - std::sys::backtrace::__rust_end_short_backtrace::hcd6e899c032809cc
  10:     0x7181c0cf54cd - __rustc[1b7c7d864259cd6]::rust_begin_unwind
  11:     0x7181bd68b190 - core::panicking::panic_fmt::ha318085fccba4a34
  12:     0x7181bd68fdfc - core::panicking::panic::h15c726c0f6f42432
  13:     0x7181bd68bb29 - core::option::unwrap_failed::h1978dcb02de840ed
  14:     0x7181bf95af32 - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State>::print_struct
  15:     0x7181bf95a3af - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State>::print_item
  16:     0x7181bf95f880 - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State>::print_stmt
  17:     0x7181bf95fc55 - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State>::print_block_maybe_unclosed
  18:     0x7181c22afd12 - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State>::print_expr_outer_attr_style
  19:     0x7181c22accc4 - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State>::print_type
  20:     0x7181c22ac016 - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State as rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::PrintState>::print_generic_args
  21:     0x7181c22ac3a4 - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State as rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::PrintState>::print_path
  22:     0x7181c22ac218 - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State>::print_type_bounds
  23:     0x7181c22ac7c5 - <rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::state::State>::print_type
  24:     0x7181c22b269f - rustc_ast_pretty[52eb923c5cfb0cd8]::pprust::ty_to_string
  25:     0x7181c1a5c3e9 - <rustc_resolve[aff44e3041396fed]::def_collector::DefCollector as rustc_ast[3ec2f256226fd62e]::visit::Visitor>::visit_ty
  26:     0x7181c1a5bfe7 - <rustc_resolve[aff44e3041396fed]::def_collector::DefCollector as rustc_ast[3ec2f256226fd62e]::visit::Visitor>::visit_fn
  27:     0x7181c1a5b225 - rustc_ast[3ec2f256226fd62e]::visit::walk_item_ctxt::<rustc_resolve[aff44e3041396fed]::def_collector::DefCollector, rustc_ast[3ec2f256226fd62e]::ast::ItemKind>
  28:     0x7181c1a58b41 - <rustc_resolve[aff44e3041396fed]::def_collector::DefCollector as rustc_ast[3ec2f256226fd62e]::visit::Visitor>::visit_item
  29:     0x7181c1a586bc - <rustc_resolve[aff44e3041396fed]::def_collector::DefCollector as rustc_ast[3ec2f256226fd62e]::visit::Visitor>::visit_crate
  30:     0x7181c1a4c7a4 - <rustc_resolve[aff44e3041396fed]::Resolver as rustc_expand[cecac1e24ff16639]::base::ResolverExpand>::visit_ast_fragment_with_placeholders
  31:     0x7181c18affb6 - <rustc_expand[cecac1e24ff16639]::expand::MacroExpander>::collect_invocations
  32:     0x7181c2775176 - <rustc_expand[cecac1e24ff16639]::expand::MacroExpander>::fully_expand_fragment
  33:     0x7181c2774bf7 - <rustc_expand[cecac1e24ff16639]::expand::MacroExpander>::expand_crate
  34:     0x7181c1d2ce7b - rustc_interface[e96dfc8419d2d906]::passes::resolver_for_lowering_raw
  35:     0x7181c1d2c28d - rustc_query_impl[f60d88ee78330afe]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f60d88ee78330afe]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[7899186a08e49cfe]::query::erase::Erased<[u8; 16usize]>>
  36:     0x7181c1d2c279 - <rustc_query_impl[f60d88ee78330afe]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[38ae99e7601dfc84]::ops::function::FnOnce<(rustc_middle[7899186a08e49cfe]::ty::context::TyCtxt, ())>>::call_once
  37:     0x7181c22ffa51 - rustc_query_system[b1d48a6028ea6356]::query::plumbing::try_execute_query::<rustc_query_impl[f60d88ee78330afe]::DynamicConfig<rustc_query_system[b1d48a6028ea6356]::query::caches::SingleCache<rustc_middle[7899186a08e49cfe]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[f60d88ee78330afe]::plumbing::QueryCtxt, false>
  38:     0x7181c22ff5c0 - rustc_query_impl[f60d88ee78330afe]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7181c25c33f3 - rustc_interface[e96dfc8419d2d906]::passes::create_and_enter_global_ctxt::<core[38ae99e7601dfc84]::option::Option<rustc_interface[e96dfc8419d2d906]::queries::Linker>, rustc_driver_impl[3d6f1070604d0a13]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  40:     0x7181c24b0304 - rustc_interface[e96dfc8419d2d906]::interface::run_compiler::<(), rustc_driver_impl[3d6f1070604d0a13]::run_compiler::{closure#0}>::{closure#1}
  41:     0x7181c234cf28 - std[1f110c8b716c47e7]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[e96dfc8419d2d906]::util::run_in_thread_with_globals<rustc_interface[e96dfc8419d2d906]::util::run_in_thread_pool_with_globals<rustc_interface[e96dfc8419d2d906]::interface::run_compiler<(), rustc_driver_impl[3d6f1070604d0a13]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  42:     0x7181c234d374 - <<std[1f110c8b716c47e7]::thread::Builder>::spawn_unchecked_<rustc_interface[e96dfc8419d2d906]::util::run_in_thread_with_globals<rustc_interface[e96dfc8419d2d906]::util::run_in_thread_pool_with_globals<rustc_interface[e96dfc8419d2d906]::interface::run_compiler<(), rustc_driver_impl[3d6f1070604d0a13]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[38ae99e7601dfc84]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7181c234e777 - std::sys::pal::unix::thread::Thread::new::thread_start::heec5752675cb1dad
  44:     0x7181bc25d70a - <unknown>
  45:     0x7181bc2e1aac - <unknown>
  46:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.88.0-nightly (5ae50d3b2 2025-04-26) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions