Skip to content

[ICE]: panicked at compiler/rustc_mir_build/src/build/expr/as_rvalue.rs:210:65 #132768

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

Closed
wxie7 opened this issue Nov 8, 2024 · 2 comments
Closed
Labels
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.

Comments

@wxie7
Copy link

wxie7 commented Nov 8, 2024

Code

#![allow(dead_code)]
#![allow(non_camel_case_types)]
pub fn main() {
    #[repr(simd)]
    enum x {
        foo,
    }
    impl ::std::cmp::PartialEq for x {
        fn eq(&self, other: &x) -> bool {
            (*self) as isize == (*other) as isize
        }
        fn ne(&self, other: &x) -> bool {
            !(*self).eq(other)
        }
    }
}

Meta

rustc --version --verbose:

rustc 1.84.0-nightly (b91a3a056 2024-11-07)
binary: rustc
commit-hash: b91a3a05609a46f73d23e0995ae7ebb4a4f429a5
commit-date: 2024-11-07
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3

Error output

error[E0517]: attribute should be applied to a struct
 --> mutant.rs:4:12
  |
4 |       #[repr(simd)]
  |              ^^^^
5 | /     enum x {
6 | |         foo,
7 | |     }
  | |_____- not a struct

thread 'rustc' panicked at compiler/rustc_mir_build/src/build/expr/as_rvalue.rs:210:65:
called `Result::unwrap()` on an `Err` value: Unknown(main::x)
stack backtrace:
...
note: compiler flags: --crate-type staticlib -C link-dead-code -C debuginfo=2 -C opt-level=3 -Z mir-opt-level=3

query stack during panic:
#0 [mir_built] building MIR for `main::<impl at mutant.rs:8:5: 8:37>::eq`
#1 [check_unsafety] unsafety-checking `main::<impl at mutant.rs:8:5: 8:37>::eq`
end of query stack
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0517`.
Backtrace

stack backtrace:
   0:     0x7f2e77c5517a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hfadad24fb33e3d1a
   1:     0x7f2e784040a6 - core::fmt::write::h42d25fbda60cd99f
   2:     0x7f2e797c3351 - std::io::Write::write_fmt::hc2819193e80b365e
   3:     0x7f2e77c54fd2 - std::sys::backtrace::BacktraceLock::print::h9450230402d77664
   4:     0x7f2e77c574d6 - std::panicking::default_hook::{{closure}}::h739047d4d787c596
   5:     0x7f2e77c57320 - std::panicking::default_hook::h203d1229480f37a5
   6:     0x7f2e76cd2269 - std[56fe22ad9ea837fd]::panicking::update_hook::<alloc[b5641001d343df5f]::boxed::Box<rustc_driver_impl[945e9afaf49c7d35]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7f2e77c57be8 - std::panicking::rust_panic_with_hook::h657fdcc17f7e2546
   8:     0x7f2e77c579ba - std::panicking::begin_panic_handler::{{closure}}::h6c1a7592f2611ed5
   9:     0x7f2e77c55629 - std::sys::backtrace::__rust_end_short_backtrace::h3e1efd1ff0b15465
  10:     0x7f2e77c5767c - rust_begin_unwind
  11:     0x7f2e746cd320 - core::panicking::panic_fmt::h41647251c9f15c53
  12:     0x7f2e74b86b06 - core::result::unwrap_failed::h54d537d424da3d7e
  13:     0x7f2e78815917 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::as_rvalue
  14:     0x7f2e78823575 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::expr_into_dest
  15:     0x7f2e7881b509 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::as_temp::{closure#0}
  16:     0x7f2e78817c09 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::as_operand
  17:     0x7f2e788178f6 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::as_operand
  18:     0x7f2e78813e78 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::as_rvalue
  19:     0x7f2e78823575 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::expr_into_dest
  20:     0x7f2e78826a42 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::expr_into_dest
  21:     0x7f2e7906682b - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::ast_block_stmts
  22:     0x7f2e7906578c - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::ast_block
  23:     0x7f2e788248f0 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::expr_into_dest
  24:     0x7f2e78826a42 - <rustc_mir_build[cc4ad6006833d10]::build::Builder>::expr_into_dest
  25:     0x7f2e787ff369 - rustc_mir_build[cc4ad6006833d10]::build::mir_build
  26:     0x7f2e78407544 - rustc_mir_transform[c62e463fc59f8bd1]::mir_built
  27:     0x7f2e78407507 - rustc_query_impl[1357963d8dd30e8b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1357963d8dd30e8b]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f0eb6ba890d0a9bb]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7f2e78b23681 - rustc_query_system[887bb79932b1d8c1]::query::plumbing::try_execute_query::<rustc_query_impl[1357963d8dd30e8b]::DynamicConfig<rustc_query_system[887bb79932b1d8c1]::query::caches::VecCache<rustc_span[db86d96c2ae2e3a4]::def_id::LocalDefId, rustc_middle[f0eb6ba890d0a9bb]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1357963d8dd30e8b]::plumbing::QueryCtxt, false>
  29:     0x7f2e78b2324d - rustc_query_impl[1357963d8dd30e8b]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f2e74868ce1 - rustc_mir_build[cc4ad6006833d10]::check_unsafety::check_unsafety
  31:     0x7f2e78e2357d - rustc_query_impl[1357963d8dd30e8b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1357963d8dd30e8b]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f0eb6ba890d0a9bb]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7f2e78e2380f - rustc_query_system[887bb79932b1d8c1]::query::plumbing::try_execute_query::<rustc_query_impl[1357963d8dd30e8b]::DynamicConfig<rustc_query_system[887bb79932b1d8c1]::query::caches::VecCache<rustc_span[db86d96c2ae2e3a4]::def_id::LocalDefId, rustc_middle[f0eb6ba890d0a9bb]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[1357963d8dd30e8b]::plumbing::QueryCtxt, false>
  33:     0x7f2e78e234c1 - rustc_query_impl[1357963d8dd30e8b]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f2e78c6912c - rustc_interface[5fea8bf9cd0b71b5]::passes::run_required_analyses
  35:     0x7f2e7920861e - rustc_interface[5fea8bf9cd0b71b5]::passes::analysis
  36:     0x7f2e792085ef - rustc_query_impl[1357963d8dd30e8b]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1357963d8dd30e8b]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f0eb6ba890d0a9bb]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7f2e79392cee - rustc_query_system[887bb79932b1d8c1]::query::plumbing::try_execute_query::<rustc_query_impl[1357963d8dd30e8b]::DynamicConfig<rustc_query_system[887bb79932b1d8c1]::query::caches::SingleCache<rustc_middle[f0eb6ba890d0a9bb]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1357963d8dd30e8b]::plumbing::QueryCtxt, false>
  38:     0x7f2e793929ce - rustc_query_impl[1357963d8dd30e8b]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7f2e7928707a - rustc_interface[5fea8bf9cd0b71b5]::interface::run_compiler::<core[5ba82ee3405aa490]::result::Result<(), rustc_span[db86d96c2ae2e3a4]::ErrorGuaranteed>, rustc_driver_impl[945e9afaf49c7d35]::run_compiler::{closure#0}>::{closure#1}
  40:     0x7f2e792cd5d0 - std[56fe22ad9ea837fd]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5fea8bf9cd0b71b5]::util::run_in_thread_with_globals<rustc_interface[5fea8bf9cd0b71b5]::util::run_in_thread_pool_with_globals<rustc_interface[5fea8bf9cd0b71b5]::interface::run_compiler<core[5ba82ee3405aa490]::result::Result<(), rustc_span[db86d96c2ae2e3a4]::ErrorGuaranteed>, rustc_driver_impl[945e9afaf49c7d35]::run_compiler::{closure#0}>::{closure#1}, core[5ba82ee3405aa490]::result::Result<(), rustc_span[db86d96c2ae2e3a4]::ErrorGuaranteed>>::{closure#0}, core[5ba82ee3405aa490]::result::Result<(), rustc_span[db86d96c2ae2e3a4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5ba82ee3405aa490]::result::Result<(), rustc_span[db86d96c2ae2e3a4]::ErrorGuaranteed>>
  41:     0x7f2e792cd9eb - <<std[56fe22ad9ea837fd]::thread::Builder>::spawn_unchecked_<rustc_interface[5fea8bf9cd0b71b5]::util::run_in_thread_with_globals<rustc_interface[5fea8bf9cd0b71b5]::util::run_in_thread_pool_with_globals<rustc_interface[5fea8bf9cd0b71b5]::interface::run_compiler<core[5ba82ee3405aa490]::result::Result<(), rustc_span[db86d96c2ae2e3a4]::ErrorGuaranteed>, rustc_driver_impl[945e9afaf49c7d35]::run_compiler::{closure#0}>::{closure#1}, core[5ba82ee3405aa490]::result::Result<(), rustc_span[db86d96c2ae2e3a4]::ErrorGuaranteed>>::{closure#0}, core[5ba82ee3405aa490]::result::Result<(), rustc_span[db86d96c2ae2e3a4]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[5ba82ee3405aa490]::result::Result<(), rustc_span[db86d96c2ae2e3a4]::ErrorGuaranteed>>::{closure#1} as core[5ba82ee3405aa490]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7f2e792ce4b9 - std::sys::pal::unix::thread::Thread::new::thread_start::hb3d6392adeea417c
  43:     0x7f2e7346bac3 - start_thread
                               at ./nptl/pthread_create.c:442:8
  44:     0x7f2e734fd850 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  45:                0x0 - <unknown>

Anything else

Could this be related to #121097 ?

@wxie7 wxie7 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 Nov 8, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 8, 2024
@cyrgani
Copy link
Contributor

cyrgani commented Nov 8, 2024

Reduced:

#[repr(simd)]
enum X {
    Foo,
}
fn eq(x: X) {
    x as isize;
}

So this is indeed the same as #121097.

@matthiaskrgr
Copy link
Member

thanks @cyrgani , closing as duplicate..

@matthiaskrgr matthiaskrgr closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

5 participants