Skip to content

ICE: compiler/rustc_codegen_llvm/src/context.rs, failed to get layout for [type error]: the type [type error] has an unknown layout #83691

Closed
@chengniansun

Description

@chengniansun

rustc 1.32 does not ICE.

Code

mod dep1 {
    extern "C" {
        pub static collision: Box<_>;
    }
}
fn main() {
    dep1::collision
}

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (48691ea6e 2021-03-29)
binary: rustc
commit-hash: 48691ea6e639640f110b43e33d4aba1f07e7415c
commit-date: 2021-03-29
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

warning: `extern` block uses type `Box<[type error]>`, which is not FFI-safe
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:31
  |
3 |         pub static collision: Box<_>;
  |                               ^^^^^^ not FFI-safe
  |
  = note: `#[warn(improper_ctypes)]` on by default
  = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
  = note: this struct has unspecified layout

error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:784:17: failed to get layout for `[type error]`: the type `[type error]` has an unknown layout

thread 'rustc' panicked at 'Box<Any>', /rustc/48691ea6e639640f110b43e33d4aba1f07e7415c/library/std/src/panic.rs:59:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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 (48691ea6e 2021-03-29) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to previous error; 1 warning emitted
Backtrace

warning: `extern` block uses type `Box<[type error]>`, which is not FFI-safe
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:3:31
  |
3 |         pub static collision: Box<_>;
  |                               ^^^^^^ not FFI-safe
  |
  = note: `#[warn(improper_ctypes)]` on by default
  = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
  = note: this struct has unspecified layout

error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:784:17: failed to get layout for `[type error]`: the type `[type error]` has an unknown layout

thread 'rustc' panicked at 'Box<Any>', /rustc/48691ea6e639640f110b43e33d4aba1f07e7415c/library/std/src/panic.rs:59:5
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::bug
   3: rustc_errors::Handler::bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_codegen_llvm::context::CodegenCx as rustc_target::abi::LayoutOf>::spanned_layout_of
   8: rustc_codegen_ssa::mir::analyze::non_ssa_locals
   9: rustc_codegen_ssa::mir::codegen_mir
  10: rustc_codegen_ssa::base::codegen_instance
  11: <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
  12: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  13: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  14: rustc_codegen_llvm::base::compile_codegen_unit
  15: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  16: rustc_interface::passes::QueryContext::enter
  17: rustc_interface::queries::Queries::ongoing_codegen
  18: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  19: rustc_span::with_source_map
  20: rustc_interface::interface::create_compiler_and_run
  21: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 (48691ea6e 2021-03-29) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to previous error; 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions