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: assertion failed: self.is_struct() || self.is_union()', compiler/rustc_middle/src/ty/adt.rs: #83505

Closed
chengniansun opened this issue Mar 26, 2021 · 0 comments · Fixed by #86444
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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

@chengniansun
Copy link

Code

#[repr(simd)]
enum Es {}
static CLs: Es;

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (52e3dffa5 2021-03-25)
binary: rustc
commit-hash: 52e3dffa50cfffdcfa145c0cc0ba48b49abc0c07
commit-date: 2021-03-25
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

error: free static item without body
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:1
  |
3 | static CLs: Es;
  | ^^^^^^^^^^^^^^-
  |               |
  |               help: provide a definition for the static: `= <expr>;`

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | / #[repr(simd)]
2 | | enum Es {}
3 | | static CLs: Es;
  | |_______________^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

error[E0517]: attribute should be applied to a struct
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:8
  |
1 | #[repr(simd)]
  |        ^^^^
2 | enum Es {}
  | ---------- not a struct

error[E0084]: unsupported representation for zero-variant enum
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | #[repr(simd)]
  | ^^^^^^^^^^^^^
2 | enum Es {}
  | ---------- zero-variant enum

thread 'rustc' panicked at 'assertion failed: self.is_struct() || self.is_union()', compiler/rustc_middle/src/ty/adt.rs:293:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: 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: rustc 1.53.0-nightly (52e3dffa5 2021-03-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [layout_raw] computing layout of `Es`
#1 [check_mod_item_types] checking item types in top-level module
end of query stack
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0084, E0517, E0601.
For more information about an error, try `rustc --explain E0084`.
Backtrace

error: free static item without body
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:1
  |
3 | static CLs: Es;
  | ^^^^^^^^^^^^^^-
  |               |
  |               help: provide a definition for the static: `= <expr>;`

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | / #[repr(simd)]
2 | | enum Es {}
3 | | static CLs: Es;
  | |_______________^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

error[E0517]: attribute should be applied to a struct
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:8
  |
1 | #[repr(simd)]
  |        ^^^^
2 | enum Es {}
  | ---------- not a struct

error[E0084]: unsupported representation for zero-variant enum
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | #[repr(simd)]
  | ^^^^^^^^^^^^^
2 | enum Es {}
  | ---------- zero-variant enum

thread 'rustc' panicked at 'assertion failed: self.is_struct() || self.is_union()', compiler/rustc_middle/src/ty/adt.rs:293:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/52e3dffa50cfffdcfa145c0cc0ba48b49abc0c07/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/52e3dffa50cfffdcfa145c0cc0ba48b49abc0c07/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/52e3dffa50cfffdcfa145c0cc0ba48b49abc0c07/library/core/src/panicking.rs:50:5
   3: rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::layout_raw_uncached
   4: rustc_middle::ty::layout::layout_raw
   5: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::layout_raw>::compute
   6: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   7: rustc_data_structures::stack::ensure_sufficient_stack
   8: rustc_query_system::query::plumbing::force_query_with_job
   9: rustc_query_system::query::plumbing::get_query_impl
  10: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_raw
  11: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
  12: rustc_typeck::check::check::check_static_inhabited
  13: rustc_typeck::check::check::check_item_type
  14: rustc_middle::hir::map::Map::visit_item_likes_in_module
  15: rustc_typeck::check::check::check_mod_item_types
  16: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  17: rustc_query_system::query::plumbing::force_query_with_job
  18: rustc_query_system::query::plumbing::get_query_impl
  19: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
  20: rustc_session::utils::<impl rustc_session::session::Session>::time
  21: rustc_typeck::check_crate
  22: rustc_interface::passes::analysis
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::force_query_with_job
  26: rustc_query_system::query::plumbing::get_query_impl
  27: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  28: rustc_interface::passes::QueryContext::enter
  29: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  30: rustc_span::with_source_map
  31: rustc_interface::interface::create_compiler_and_run
  32: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: 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: rustc 1.53.0-nightly (52e3dffa5 2021-03-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [layout_raw] computing layout of `Es`
#1 [check_mod_item_types] checking item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0084, E0517, E0601.
For more information about an error, try `rustc --explain E0084`.

@chengniansun chengniansun 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 26, 2021
fanninpm added a commit to fanninpm/glacier that referenced this issue Mar 26, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 27, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jun 19, 2021
…tichaut

Fix ICE with `#[repr(simd)]` on enum

This pull request fixes rust-lang#83505. `#[repr(simd)]` may only be applied to structs, which correctly causes `E0517` for the example given in rust-lang#83505, but the compiler attempts to recover from this error, which leads to an ICE later, when `.non_enum_variant()` is called on the `AdtDef`. I have added a check that prevents this from happening.
@bors bors closed this as completed in 84d6c68 Jun 19, 2021
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. glacier ICE tracked in rust-lang/glacier. 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

Successfully merging a pull request may close this issue.

2 participants