Closed
Description
#![feature(allocator_api)]
struct B {}
struct A<'ctx> {
b: &'ctx B,
}
unsafe impl std::alloc::Allocator for A<'_> {
fn allocate(
&self,
layout: std::alloc::Layout,
) -> Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError> {
Err(std::alloc::AllocError)
}
unsafe fn deallocate(&self, ptr: std::ptr::NonNull<u8>, layout: std::alloc::Layout) {}
}
fn main() {
let b = B {};
let a = A { b: &b };
Box::new_in(1, a);
}
thread 'rustc' panicked at 'assertion failed: i < this.fields.count()', /rustc/547a6ffee0cf4da9929a9e3d49546dc87d607735/compiler/rustc_middle/src/ty/layout.rs:2290: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.58.0-nightly (547a6ffee 2021-10-21) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
warning: `ttt` (bin "ttt") generated 5 warnings
error: could not compile `ttt`; 5 warnings emitted