Closed
Description
Code
This code causes rustc to ICE:
#![feature(ptr_metadata)]
use std::alloc::Layout;
use std::ptr::Pointee;
trait RowOp {
type Config;
}
struct Numbers;
impl RowOp for Numbers {
type Config = ();
}
struct Func<T: RowOp> { _config: T::Config }
struct Inner<T: Pointee + ?Sized> { _meta: T::Metadata }
pub fn main() {
// ICE caused by this line
let _layout = Layout::new::<Inner<Func<Numbers>>>();
}
Meta
rustc --version --verbose
:
rustc 1.59.0-nightly (e95e084a1 2021-12-19) running on x86_64-unknown-linux-gnu
Error output
Compiling playground v0.0.1 (/playground)
error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:867:13: failed to get layout for `Inner<Func<Numbers>>`: the type `<Func<Numbers> as Pointee>::Metadata` has an unknown layout
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e95e084a14870a718c712936ab5a8f8cd0159485/compiler/rustc_errors/src/lib.rs:1115:9
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.59.0-nightly (e95e084a1 2021-12-19) 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:
end of query stack
error: could not compile `playground`
Backtrace
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e95e084a14870a718c712936ab5a8f8cd0159485/compiler/rustc_errors/src/lib.rs:1115:9
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
1: std::panic::panic_any::<rustc_errors::ExplicitBug>
2: <rustc_errors::HandlerInner>::span_bug::<rustc_span::span_encoding::Span>
3: <rustc_errors::Handler>::span_bug::<rustc_span::span_encoding::Span>
4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>
5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
7: <rustc_codegen_llvm::context::CodegenCx as rustc_middle::ty::layout::LayoutOfHelpers>::handle_layout_err
8: <rustc_codegen_llvm::context::CodegenCx as rustc_middle::ty::layout::LayoutOf>::spanned_layout_of::{closure#0}
9: rustc_codegen_llvm::debuginfo::metadata::create_struct_stub
10: rustc_codegen_llvm::debuginfo::metadata::type_metadata
11: <alloc::vec::Vec<core::option::Option<&rustc_codegen_llvm::llvm_::ffi::Metadata>> as alloc::vec::spec_from_iter::SpecFromIter<core::option::Option<&rustc_codegen_llvm::llvm_::ffi::Metadata>, core::iter::adapters::filter_map::FilterMap<core::iter::adapters::zip::Zip<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::subst::GenericArg>>, alloc::vec::into_iter::IntoIter<rustc_span::symbol::Symbol>>, <rustc_codegen_llvm::context::CodegenCx as rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods>::dbg_scope_fn::get_template_parameters::{closure#0}>>>::from_iter
12: <rustc_codegen_llvm::context::CodegenCx as rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods>::dbg_scope_fn::get_template_parameters
13: <rustc_codegen_llvm::context::CodegenCx as rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods>::dbg_scope_fn
14: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
15: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
16: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::symbol::Symbol, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>
17: rustc_codegen_llvm::base::compile_codegen_unit
18: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
19: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
20: <rustc_interface::queries::Queries>::ongoing_codegen
21: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
22: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
23: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.