Repository: rust
Issue: ICE during codegen of unsize coercion on `#[repr(C)]` struct
Labels: I-ICE,T-compiler,C-bug,requires-nightly,glacier,S-bug-has-test,A-repr

Very similar to #46152. I ran into this while creating a test case for PR #54383.

```rust
#![feature(unsize, coerce_unsized)]

use std::{
    ops::CoerceUnsized,
    marker::Unsize,
};

#[repr(C)]
struct Ptr<T: ?Sized>(Box<T>);

impl<T: ?Sized, U: ?Sized> CoerceUnsized<Ptr<U>> for Ptr<T>
where
    T: Unsize<U>,
{}


fn main() {
    let foo = Ptr(Box::new(5)) as Ptr<dyn ::std::any::Any>;
}
```

Error message:

```
error: internal compiler error: librustc_codegen_llvm/mir/rvalue.rs:268: by-ref operand
OperandRef(Ref((%"Ptr<i32>"*:  %1 = alloca %"Ptr<i32>", align 8), None, Align { abi_pow2: 3, pref_pow2: 3 }) @ TyLayout { ty: Ptr<i32>, details: LayoutDetails { variants: Single { index: 0 }, fields: Arbitrary { offsets: [Size { raw: 0 }], memory_index: [0] }, abi: Aggregate { sized: true }, align: Align { abi_pow2: 3, pref_pow2: 3 }, size: Size { raw: 8 } } })
in codegen_rvalue_operand
```

EDIT:
<details>  current ICE message:

```
error: internal compiler error: /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/compiler/rustc_codegen_ssa/src/mir/rvalue.rs:241:33: by-ref operand OperandRef(Ref((ptr:  %1 = alloca %4, align 8), None, Align(8 bytes)) @ TyAndLayout { ty: Ptr<i32>, layout: Layout { size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [Size(0 bytes)], memory_index: [0] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 } } }) in `codegen_rvalue_operand`

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/compiler/rustc_errors/src/lib.rs:1644:9
stack backtrace:
   0:     0x7f329672c81a - std::backtrace_rs::backtrace::libunwind::trace::h26518014dbf31aba
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f329672c81a - std::backtrace_rs::backtrace::trace_unsynchronized::ha516581d0aef3757
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f329672c81a - std::sys_common::backtrace::_print_fmt::h9eca712360b21da0
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f329672c81a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h528fecd217131eb4
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f329679044e - core::fmt::write::h073da6791f3f2ff7
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/core/src/fmt/mod.rs:1254:17
   5:     0x7f329671f395 - std::io::Write::write_fmt::h51f8756996066b5a
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/io/mod.rs:1698:15
   6:     0x7f329672c5e5 - std::sys_common::backtrace::_print::h5b4ffde9ddd340d3
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f329672c5e5 - std::sys_common::backtrace::print::hde4ce191c0ed53d2
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f329672f35f - std::panicking::default_hook::{{closure}}::h23a2d3c2d62785b5
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/panicking.rs:271:22
   9:     0x7f329672f09b - std::panicking::default_hook::hfe56491cf86bf314
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/panicking.rs:290:9
  10:     0x7f3299a84f35 - <rustc_driver_impl[ad8fc07c03d45871]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[ee581b2e0272cb3e]::ops::function::FnOnce<(&core[ee581b2e0272cb3e]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f329672fb9d - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hfa9e4663303a5377
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/alloc/src/boxed.rs:2002:9
  12:     0x7f329672fb9d - std::panicking::rust_panic_with_hook::hb3c1c1d27d072101
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/panicking.rs:696:13
  13:     0x7f3299fa5881 - std[f9545795ea4997bf]::panicking::begin_panic::<rustc_errors[3a23900e9dcec074]::ExplicitBug>::{closure#0}
  14:     0x7f3299fa1996 - std[f9545795ea4997bf]::sys_common::backtrace::__rust_end_short_backtrace::<std[f9545795ea4997bf]::panicking::begin_panic<rustc_errors[3a23900e9dcec074]::ExplicitBug>::{closure#0}, !>
  15:     0x7f3299fa1926 - std[f9545795ea4997bf]::panicking::begin_panic::<rustc_errors[3a23900e9dcec074]::ExplicitBug>
  16:     0x7f3299ffcfb6 - std[f9545795ea4997bf]::panic::panic_any::<rustc_errors[3a23900e9dcec074]::ExplicitBug>
  17:     0x7f3299ffaea6 - <rustc_errors[3a23900e9dcec074]::HandlerInner>::bug::<&alloc[e80928591b456ef9]::string::String>
  18:     0x7f3299ffab70 - <rustc_errors[3a23900e9dcec074]::Handler>::bug::<&alloc[e80928591b456ef9]::string::String>
  19:     0x7f3299ff1b2b - rustc_middle[267d604f42fb2b42]::util::bug::opt_span_bug_fmt::<rustc_span[48752dc4b679ffbb]::span_encoding::Span>::{closure#0}
  20:     0x7f3299ff094a - rustc_middle[267d604f42fb2b42]::ty::context::tls::with_opt::<rustc_middle[267d604f42fb2b42]::util::bug::opt_span_bug_fmt<rustc_span[48752dc4b679ffbb]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f3299ff0916 - rustc_middle[267d604f42fb2b42]::ty::context::tls::with_context_opt::<rustc_middle[267d604f42fb2b42]::ty::context::tls::with_opt<rustc_middle[267d604f42fb2b42]::util::bug::opt_span_bug_fmt<rustc_span[48752dc4b679ffbb]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f3299ff1a76 - rustc_middle[267d604f42fb2b42]::util::bug::opt_span_bug_fmt::<rustc_span[48752dc4b679ffbb]::span_encoding::Span>
  23:     0x7f3298029533 - rustc_middle[267d604f42fb2b42]::util::bug::bug_fmt
  24:     0x7f329839b2ec - <rustc_codegen_ssa[69e83e84c4ffa06]::mir::FunctionCx<rustc_codegen_llvm[d9e68a931594c80d]::builder::Builder>>::codegen_rvalue_operand
  25:     0x7f3298362779 - rustc_codegen_ssa[69e83e84c4ffa06]::mir::codegen_mir::<rustc_codegen_llvm[d9e68a931594c80d]::builder::Builder>
  26:     0x7f3298fb42f3 - rustc_codegen_llvm[d9e68a931594c80d]::base::compile_codegen_unit::module_codegen
  27:     0x7f3298fb1d6f - <rustc_codegen_llvm[d9e68a931594c80d]::LlvmCodegenBackend as rustc_codegen_ssa[69e83e84c4ffa06]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  28:     0x7f3298fafed8 - rustc_codegen_ssa[69e83e84c4ffa06]::base::codegen_crate::<rustc_codegen_llvm[d9e68a931594c80d]::LlvmCodegenBackend>
  29:     0x7f3298faf7ee - <rustc_codegen_llvm[d9e68a931594c80d]::LlvmCodegenBackend as rustc_codegen_ssa[69e83e84c4ffa06]::traits::backend::CodegenBackend>::codegen_crate
  30:     0x7f3298c17611 - <rustc_session[6aba769f1422c309]::session::Session>::time::<alloc[e80928591b456ef9]::boxed::Box<dyn core[ee581b2e0272cb3e]::any::Any>, rustc_interface[dce09aa29aba2b19]::passes::start_codegen::{closure#0}>
  31:     0x7f3298c17139 - rustc_interface[dce09aa29aba2b19]::passes::start_codegen
  32:     0x7f3298c13348 - <rustc_middle[267d604f42fb2b42]::ty::context::GlobalCtxt>::enter::<<rustc_interface[dce09aa29aba2b19]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[ee581b2e0272cb3e]::result::Result<alloc[e80928591b456ef9]::boxed::Box<dyn core[ee581b2e0272cb3e]::any::Any>, rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>>
  33:     0x7f3298c11974 - <rustc_interface[dce09aa29aba2b19]::queries::Queries>::ongoing_codegen
  34:     0x7f3298c10f41 - <rustc_interface[dce09aa29aba2b19]::interface::Compiler>::enter::<rustc_driver_impl[ad8fc07c03d45871]::run_compiler::{closure#1}::{closure#2}, core[ee581b2e0272cb3e]::result::Result<core[ee581b2e0272cb3e]::option::Option<rustc_interface[dce09aa29aba2b19]::queries::Linker>, rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>>
  35:     0x7f3298c0c0e0 - rustc_span[48752dc4b679ffbb]::with_source_map::<core[ee581b2e0272cb3e]::result::Result<(), rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>, rustc_interface[dce09aa29aba2b19]::interface::run_compiler<core[ee581b2e0272cb3e]::result::Result<(), rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>, rustc_driver_impl[ad8fc07c03d45871]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  36:     0x7f3298c0b689 - std[f9545795ea4997bf]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dce09aa29aba2b19]::util::run_in_thread_pool_with_globals<rustc_interface[dce09aa29aba2b19]::interface::run_compiler<core[ee581b2e0272cb3e]::result::Result<(), rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>, rustc_driver_impl[ad8fc07c03d45871]::run_compiler::{closure#1}>::{closure#0}, core[ee581b2e0272cb3e]::result::Result<(), rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ee581b2e0272cb3e]::result::Result<(), rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>>
  37:     0x7f329931111a - <<std[f9545795ea4997bf]::thread::Builder>::spawn_unchecked_<rustc_interface[dce09aa29aba2b19]::util::run_in_thread_pool_with_globals<rustc_interface[dce09aa29aba2b19]::interface::run_compiler<core[ee581b2e0272cb3e]::result::Result<(), rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>, rustc_driver_impl[ad8fc07c03d45871]::run_compiler::{closure#1}>::{closure#0}, core[ee581b2e0272cb3e]::result::Result<(), rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[ee581b2e0272cb3e]::result::Result<(), rustc_span[48752dc4b679ffbb]::ErrorGuaranteed>>::{closure#1} as core[ee581b2e0272cb3e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f3296739c13 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h31d31ee934fae5d7
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/alloc/src/boxed.rs:1988:9
  39:     0x7f3296739c13 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h235705d08d5be362
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/alloc/src/boxed.rs:1988:9
  40:     0x7f3296739c13 - std::sys::unix::thread::Thread::new::thread_start::h8f78f28fa2155287
                               at /rustc/a266f11990d9544ee408e213e1eec8cc9eb032b7/library/std/src/sys/unix/thread.rs:108:17
  41:     0x7f3296600609 - start_thread
  42:     0x7f3296523133 - clone
  43:                0x0 - <unknown>

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.70.0-nightly (a266f1199 2023-03-22) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `playground` (bin "playground") generated 1 warning (run `cargo fix --bin "playground"` to apply 1 suggestion)
```
</details>