Skip to content

ICE while computing layout with uninhabited type #88150

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
joshlf opened this issue Aug 19, 2021 · 3 comments
Closed

ICE while computing layout with uninhabited type #88150

joshlf opened this issue Aug 19, 2021 · 3 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) 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

@joshlf
Copy link
Contributor

joshlf commented Aug 19, 2021

Code

use core::marker::PhantomData;

pub struct Foo<T: ?Sized, A>(
    PhantomData<(A, T)>,
);

enum Never {}

impl<T: ?Sized> Foo<T, Never> {
    fn new_foo() -> Foo<T, Never> {
        Foo(PhantomData)
    }
}

fn main() {
    let _ = Foo::<(), Never>::new_foo();
    let _ = Foo::<[()], Never>::new_foo(); // <-- This line causes the ICE
}

(playground link)

Meta

Running on the Rust Playground using 1.54.0 stable. Verified that the bug exists in the current beta and stable releases as well.

Error output

Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at 'assertion failed: layout.abi.is_uninhabited()', compiler/rustc_middle/src/ty/layout.rs:228:21
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.56.0-nightly (30a0a9b69 2021-08-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [layout_raw] computing layout of `(Never, [()])`
end of query stack
error: could not compile `playground`
Backtrace

Compiling playground v0.0.1 (/playground)
thread 'rustc' panicked at 'assertion failed: layout.abi.is_uninhabited()', compiler/rustc_middle/src/ty/layout.rs:237:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/core/src/panicking.rs:50:5
   3: rustc_middle::ty::layout::layout_raw
   4: rustc_query_impl::<impl rustc_query_system::query::config::QueryAccessors<rustc_query_impl::plumbing::QueryCtxt> for rustc_query_impl::queries::layout_raw>::compute
   5: rustc_query_system::query::plumbing::get_query_impl
   6: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_raw
   7: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
   8: <rustc_codegen_llvm::context::CodegenCx as rustc_target::abi::LayoutOf>::spanned_layout_of
   9: rustc_codegen_llvm::debuginfo::metadata::create_struct_stub
  10: rustc_codegen_llvm::debuginfo::metadata::prepare_tuple_metadata
  11: rustc_codegen_llvm::debuginfo::metadata::type_metadata
  12: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  13: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  14: rustc_codegen_llvm::debuginfo::metadata::set_members_of_composite_type
  15: rustc_codegen_llvm::debuginfo::metadata::RecursiveTypeDescription::finalize
  16: rustc_codegen_llvm::debuginfo::metadata::type_metadata
  17: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  18: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  19: rustc_codegen_llvm::debuginfo::metadata::MemberDescriptionFactory::create_member_descriptions
  20: rustc_codegen_llvm::debuginfo::metadata::RecursiveTypeDescription::finalize
  21: rustc_codegen_llvm::debuginfo::metadata::type_metadata
  22: rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::dbg_scope_fn::get_containing_scope
  23: rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::dbg_scope_fn
  24: rustc_codegen_ssa::mir::codegen_mir
  25: rustc_codegen_ssa::base::codegen_instance
  26: <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
  27: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  29: rustc_codegen_llvm::base::compile_codegen_unit
  30: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  31: rustc_interface::passes::QueryContext::enter
  32: rustc_interface::queries::Queries::ongoing_codegen
  33: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  34: rustc_span::with_source_map
  35: rustc_interface::interface::create_compiler_and_run
  36: 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.54.0 (a178d0322 2021-07-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [layout_raw] computing layout of `(Never, [()])`
end of query stack
error: could not compile `playground`

@joshlf joshlf 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 Aug 19, 2021
@hkratz
Copy link
Contributor

hkratz commented Aug 19, 2021

This bug seems related to debug info generation, it reproduces with rustc --edition=2018 src/main.rs -C debuginfo=2 but not with rustc --edition=2018 src/main.rs -C debuginfo=0 or rustc --edition=2018 src/main.rs -C debuginfo=1.

@hkratz
Copy link
Contributor

hkratz commented Aug 19, 2021

$ RUST_BACKTRACE=1 rustc +nightly --edition=2018 src/main.rs --crate-type bin -C debuginfo=2
thread 'rustc' panicked at 'assertion failed: layout.abi.is_uninhabited()', compiler/rustc_middle/src/ty/layout.rs:228:21
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: rustc_middle::ty::layout::layout_raw
   4: rustc_query_system::query::plumbing::get_query_impl
   5: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::layout_raw
   6: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
   7: rustc_codegen_llvm::debuginfo::metadata::create_struct_stub
   8: rustc_codegen_llvm::debuginfo::metadata::prepare_tuple_metadata
   9: rustc_codegen_llvm::debuginfo::metadata::type_metadata
  10: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  12: rustc_codegen_llvm::debuginfo::metadata::set_members_of_composite_type
  13: rustc_codegen_llvm::debuginfo::metadata::RecursiveTypeDescription::finalize
  14: rustc_codegen_llvm::debuginfo::metadata::type_metadata
  15: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  16: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  17: rustc_codegen_llvm::debuginfo::metadata::MemberDescriptionFactory::create_member_descriptions
  18: rustc_codegen_llvm::debuginfo::metadata::RecursiveTypeDescription::finalize
  19: rustc_codegen_llvm::debuginfo::metadata::type_metadata
  20: rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::dbg_scope_fn::get_containing_scope
  21: rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::dbg_scope_fn
  22: rustc_codegen_llvm::debuginfo::<impl rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods for rustc_codegen_llvm::context::CodegenCx>::create_function_debug_context
  23: rustc_codegen_ssa::mir::codegen_mir
  24: rustc_codegen_ssa::base::codegen_instance
  25: <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
  26: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  28: rustc_codegen_llvm::base::compile_codegen_unit
  29: rustc_codegen_ssa::base::codegen_crate
  30: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  31: rustc_interface::queries::Queries::ongoing_codegen
  32: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  33: rustc_span::with_source_map
  34: scoped_tls::ScopedKey<T>::set

@hkratz
Copy link
Contributor

hkratz commented Aug 19, 2021

@rustbot label +A-debuginfo

@rustbot rustbot added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Aug 19, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 3, 2021
…estebank

Type can be unsized and uninhabited

Fix rust-lang#88150.
@bors bors closed this as completed in 570dc70 Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) 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

Successfully merging a pull request may close this issue.

3 participants