Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: computed impossible repr (packed enum?): Foo #138241

Closed
matthiaskrgr opened this issue Mar 8, 2025 · 1 comment · Fixed by #138253
Closed

ICE: computed impossible repr (packed enum?): Foo #138241

matthiaskrgr opened this issue Mar 8, 2025 · 1 comment · Fixed by #138253
Assignees
Labels
A-repr Area: the `#[repr(stuff)]` attribute C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 8, 2025

snippet:

//@compile-flags: --crate-type=lib
#[repr()]
#[repr(packed)]
pub enum Foo {
    Bar,
    Baz(i32),
}

Version information

rustc 1.87.0-nightly (07292cccc 2025-03-08)
binary: rustc
commit-hash: 07292ccccde8b64d87036b2f90b70bc54ab68456
commit-date: 2025-03-08
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --crate-type=lib

Program output

warning: unused attribute
 --> /tmp/icemaker_global_tempdir.hV6iHi5L3CPm/rustc_testrunner_tmpdir_reporting.kj97BZMzsyE0/mvce.rs:1:1
  |
1 | #[repr()]
  | ^^^^^^^^^ help: remove this attribute
  |
  = note: attribute `repr` with an empty list has no effect
  = note: `#[warn(unused_attributes)]` on by default

warning: 1 warning emitted

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: computed impossible repr (packed enum?): Foo
  |
  = note: delayed at compiler/rustc_ty_utils/src/layout.rs:124:18
             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::DiagCtxtHandle>::delayed_bug::<alloc::string::String>
             4: rustc_ty_utils::layout::map_error
             5: rustc_ty_utils::layout::layout_of_uncached
             6: rustc_ty_utils::layout::layout_of
             7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
             8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::ty::Ty>, rustc_middle::query::erase::Erased<[u8; 16]>>, false, true, false>, rustc_query_impl::plumbing::QueryCtxt, false>
             9: rustc_query_impl::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
            10: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::ty::Ty>, rustc_middle::query::erase::Erased<[u8; 16]>>>
            11: <rustc_lint::BuiltinCombinedModuleLateLintPass as rustc_lint::passes::LateLintPass>::check_item
            12: <rustc_lint::late::LateContextAndPass<rustc_lint::BuiltinCombinedModuleLateLintPass> as rustc_hir::intravisit::Visitor>::visit_nested_item
            13: rustc_lint::lint_mod
            14: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
            15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalModDefId, rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
            16: rustc_query_impl::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
            17: rustc_lint::late::check_crate::{closure#1}
            18: rustc_lint::late::check_crate
            19: rustc_interface::passes::analysis
            20: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
            21: 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>
            22: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
            23: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
            24: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
            25: 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}, ()>
            26: <<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}
            27: std::sys::pal::unix::thread::Thread::new::thread_start
            28: <unknown>
            29: <unknown>
          

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 (07292cccc 2025-03-08) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
end of query stack

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 8, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 8, 2025
@matthiaskrgr matthiaskrgr added the A-repr Area: the `#[repr(stuff)]` attribute label Mar 8, 2025
@mu001999
Copy link
Contributor

mu001999 commented Mar 9, 2025

@rustbot claim

@bors bors closed this as completed in 469f48d Mar 9, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 9, 2025
Rollup merge of rust-lang#138253 - mu001999-contrib:fix-138241, r=jdonszelmann

Continue to check attr if meet empty repr for adt

Fixes rust-lang#138241

Returning while checking ReprEmpty results in missing the check for the next repr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-repr Area: the `#[repr(stuff)]` attribute C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants