Repository: rust
Issue: ICE when using size_of on associated type projection that may not be Sized
Labels: I-ICE,P-medium,T-compiler,regression-from-stable-to-stable,C-bug,S-bug-has-test

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->
I tried this code. However it triggers an internal compiler error (ICE).

### Code

```Rust
trait MyTrait {
    type Target: ?Sized;
}

impl<A: ?Sized> MyTrait for A {
    type Target = A;
}

fn main() {
    bug_run::<dyn MyTrait<Target = u8>>();
}

fn bug_run<T: ?Sized>()
where
    <T as MyTrait>::Target: Sized,
{
    bug::<T>();
}

fn bug<T>() {
    std::mem::size_of::<T>();
}

```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```

rustc 1.74.0-nightly (2f5df8a94 2023-08-31)
binary: rustc
commit-hash: 2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19
commit-date: 2023-08-31
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0
```

### Error output

```
warning: unused return value of `std::mem::size_of` that must be used
  --> bug_1.rs:21:5
   |
21 |     std::mem::size_of::<T>();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
   |
21 |     let _ = std::mem::size_of::<T>();
   |     +++++++
thread 'rustc' panicked at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/compiler/rustc_codegen_ssa/src/mir/rvalue.rs:675:25:
assertion failed: bx.cx().type_is_sized(ty)
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

```
thread 'rustc' panicked at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/compiler/rustc_codegen_ssa/src/mir/rvalue.rs:675:25:
assertion failed: bx.cx().type_is_sized(ty)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/library/std/src/panicking.rs:619:5
   1: core::panicking::panic_fmt
             at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/2f5df8a94bb3c5fae4e3fcbfc8ef20f1f976cb19/library/core/src/panicking.rs:127:5
   3: <rustc_codegen_ssa::mir::FunctionCx<rustc_codegen_llvm::builder::Builder>>::codegen_rvalue_operand
   4: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
   5: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
   6: rustc_codegen_llvm::base::compile_codegen_unit
   7: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
   8: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
   9: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  10: rustc_interface::passes::start_codegen
  11: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
  12: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: 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: please attach the file at `/home/coding/rustc-ice-2023-09-01T12:24:17.5235892Z-11165.txt` to your bug report

query stack during panic:
end of query stack
warning: 1 warning emitted
```

</p>
</details>
I'm confused because empty query stack😥