rust-lang / rust-lang/rust

ICE: unpretty dies because of invalid repr

Open
#138,534 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-pretty A-repr C-bug I-ICE S-bug-has-test T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: -Zunpretty=expanded
#[repr(bool)]
pub enum TopFg {
    Bar,
}

original:

#[derive(Debug)]
#[repr(bool)]
pub enum TopFg {
    Bar,
}

Version information

rustc 1.87.0-nightly (aa95b9648 2025-03-15)
binary: rustc
commit-hash: aa95b9648ad0383a3fd73b5271dd86f848b7c00c
commit-date: 2025-03-15
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zunpretty=expanded

Program output

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error[E0552]: unrecognized representation hint
 --> /tmp/icemaker_global_tempdir.FwSxYTjb3IWb/rustc_testrunner_tmpdir_reporting.9LnNTYsaI8WQ/mvce.rs:1:8
  |
1 | #[repr(bool)]
  |        ^^^^
  |
  = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize`
note: delayed at compiler/rustc_attr_parsing/src/context.rs:96:24
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::diagnostic::Diag>::delay_as_bug
         4: <rustc_attr_parsing::attributes::repr::ReprParser as rustc_attr_parsing::attributes::CombineAttributeParser>::extend
         5: <<rustc_attr_parsing::attributes::Combine<rustc_attr_parsing::attributes::repr::ReprParser> as rustc_attr_parsing::attributes::AttributeParser>::ATTRIBUTES::{closure#0} as core::ops::function::FnOnce<(&mut rustc_attr_parsing::attributes::Combine<rustc_attr_parsing::attributes::repr::ReprParser>, &rustc_attr_parsing::context::AcceptContext, &rustc_attr_parsing::parser::ArgParser)>>::call_once
         6: rustc_attr_parsing::context::ATTRIBUTE_MAPPING::{closure#0}::{closure#12}
         7: <rustc_lint::BuiltinCombinedEarlyLintPass as rustc_lint::passes::EarlyLintPass>::check_item
         8: <rustc_lint::early::EarlyContextAndPass<rustc_lint::BuiltinCombinedEarlyLintPass> as rustc_ast::visit::Visitor>::visit_item
         9: rustc_interface::passes::early_lint_checks
        10: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::early_lint_checks::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
        11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        12: rustc_query_impl::query_impl::early_lint_checks::get_query_non_incr::__rust_end_short_backtrace
        13: rustc_interface::passes::create_and_enter_global_ctxt::<(), rustc_driver_impl::run_compiler::{closure#0}::{closure#1}>::{closure#2}::{closure#0}
        14: <rustc_interface::passes::create_and_enter_global_ctxt<(), rustc_driver_impl::run_compiler::{closure#0}::{closure#1}>::{closure#2} as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#1})>>::call_once::{shim:vtable#0}
        15: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        16: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        17: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        18: std::sys::pal::unix::thread::Thread::new::thread_start
        19: <unknown>
        20: <unknown>
 --> /tmp/icemaker_global_tempdir.FwSxYTjb3IWb/rustc_testrunner_tmpdir_reporting.9LnNTYsaI8WQ/mvce.rs:1:8
  |
1 | #[repr(bool)]
  |        ^^^^

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.87.0-nightly (aa95b9648 2025-03-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unpretty=expanded -Z dump-mir-dir=dir

query stack during panic:
end of query stack

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the ICE with the provided #[repr(bool)] example and -Zunpretty=expanded command. Start with compiler/rustc_attr_parsing/src/context.rs:96 and the ReprParser path shown in the diagnostic. Done means the invalid representation reports a normal error without causing an internal compiler error during unpretty expansion.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.