Repository: rust
Issue: Compilation failed when emitting mir
Labels: I-ICE,T-compiler,C-bug,S-needs-repro

<!--
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/
-->

### Code

```Rust
fn main() {
    ()
}
```

### Command
```
cargo rustc --profile=check --  --emit=mir
```

### 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.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: x86_64-pc-windows-msvc
release: 1.77.2
LLVM version: 17.0.6
```

### Error output

```
thread 'copy LTO artifacts for 6qqtl33vkt97x99' panicked at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\compiler\rustc_codegen_ssa\src\back\write.rs:894:5:
assertion failed: module_config.emit_obj != EmitObj::None
stack backtrace:
   0:     0x7ffacf342902 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h708c0e6d07ee75bc
   1:     0x7ffacf375a5d - core::fmt::write::ha562f117fc8493e6
   2:     0x7ffacf338f91 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h73b3c4d73d82ca2e
   3:     0x7ffacf34272a - std::sys_common::backtrace::lock::h300ba94956ddd24a
   4:     0x7ffacf345ac9 - std::panicking::default_hook::hc9d04f0d76a9742b
   5:     0x7ffacf345785 - std::panicking::default_hook::hc9d04f0d76a9742b
   6:     0x7ffa8cbeb863 - <tracing_subscriber[c0eceff03426eead]::fmt::format::Writer>::write_fmt
   7:     0x7ffacf3460d3 - std::panicking::rust_panic_with_hook::h05ca8ac23cc77c65
   8:     0x7ffacf345f3b - <std::panicking::begin_panic_handler::StaticStrPayload as core::panic::PanicPayload>::take_box::hb0fb1300a6d60333
   9:     0x7ffacf343209 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h708c0e6d07ee75bc
  10:     0x7ffacf345c46 - rust_begin_unwind
  11:     0x7ffacf39b2c7 - core::panicking::panic_fmt::h66fb88c8a7d9ff95
  12:     0x7ffacf39b3a2 - core::panicking::panic::hc78b6d0617c02f64
  13:     0x7ffa88df31cb - <rustc_codegen_llvm[4b6651d80c2e5a32]::LlvmCodegenBackend as rustc_codegen_ssa[dba68bb7903231d2]::traits::backend::CodegenBackend>::link
  14:     0x7ffa88e0498b - <rustc_codegen_llvm[4b6651d80c2e5a32]::LlvmCodegenBackend as rustc_codegen_ssa[dba68bb7903231d2]::traits::backend::CodegenBackend>::link
  15:     0x7ffacf35803c - std::sys::pal::windows::thread::Thread::new::h51a32cdc9f29bad5
  16:     0x7ffb3fa6257d - BaseThreadInitThunk
  17:     0x7ffb40d6aa48 - RtlUserThreadStart

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: rustc 1.77.2 (25ef9e3d8 2024-04-09) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread 'coordinator' panicked at compiler\rustc_middle\src\util\bug.rs:36:26:
/rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\compiler\rustc_codegen_ssa\src\back\write.rs:1588:29: worker thread panicked
stack backtrace:
   0:     0x7ffacf342902 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h708c0e6d07ee75bc
   1:     0x7ffacf375a5d - core::fmt::write::ha562f117fc8493e6
   2:     0x7ffacf338f91 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h73b3c4d73d82ca2e
   3:     0x7ffacf34272a - std::sys_common::backtrace::lock::h300ba94956ddd24a
   4:     0x7ffacf345ac9 - std::panicking::default_hook::hc9d04f0d76a9742b
   5:     0x7ffacf345785 - std::panicking::default_hook::hc9d04f0d76a9742b
   6:     0x7ffa8cbeb863 - <tracing_subscriber[c0eceff03426eead]::fmt::format::Writer>::write_fmt
   7:     0x7ffacf3460d3 - std::panicking::rust_panic_with_hook::h05ca8ac23cc77c65
   8:     0x7ffa8de87e84 - <rustc_middle[3a1ce97b5b0524ba]::ty::VariantFlags as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
   9:     0x7ffa8de82159 - <rustc_middle[3a1ce97b5b0524ba]::ty::VariantFlags as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
  10:     0x7ffa8df0b0f3 - rustc_middle[3a1ce97b5b0524ba]::dep_graph::dep_node::DEP_KIND_VARIANTS::panic_cold_explicit
  11:     0x7ffa8dee005e - rustc_middle[3a1ce97b5b0524ba]::util::bug::bug_fmt
  12:     0x7ffa8dedf6fd - rustc_middle[3a1ce97b5b0524ba]::ty::util::is_doc_notable_trait
  13:     0x7ffa8dedf6ca - rustc_middle[3a1ce97b5b0524ba]::ty::util::is_doc_notable_trait
  14:     0x7ffa8dedff82 - rustc_middle[3a1ce97b5b0524ba]::util::bug::bug_fmt
  15:     0x7ffa88df5c59 - <rustc_codegen_llvm[4b6651d80c2e5a32]::LlvmCodegenBackend as rustc_codegen_ssa[dba68bb7903231d2]::traits::backend::CodegenBackend>::link
  16:     0x7ffa88e04def - <rustc_codegen_llvm[4b6651d80c2e5a32]::LlvmCodegenBackend as rustc_codegen_ssa[dba68bb7903231d2]::traits::backend::CodegenBackend>::link
  17:     0x7ffacf35803c - std::sys::pal::windows::thread::Thread::new::h51a32cdc9f29bad5
  18:     0x7ffb3fa6257d - BaseThreadInitThunk
  19:     0x7ffb40d6aa48 - RtlUserThreadStart

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: rustc 1.77.2 (25ef9e3d8 2024-04-09) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread 'rustc' panicked at compiler\rustc_middle\src\util\bug.rs:36:26:
/rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\compiler\rustc_codegen_ssa\src\back\write.rs:1956:17: panic during codegen/LLVM phase
stack backtrace:
   0:     0x7ffacf342902 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h708c0e6d07ee75bc
   1:     0x7ffacf375a5d - core::fmt::write::ha562f117fc8493e6
   2:     0x7ffacf338f91 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h73b3c4d73d82ca2e
   3:     0x7ffacf34272a - std::sys_common::backtrace::lock::h300ba94956ddd24a
   4:     0x7ffacf345ac9 - std::panicking::default_hook::hc9d04f0d76a9742b
   5:     0x7ffacf345785 - std::panicking::default_hook::hc9d04f0d76a9742b
   6:     0x7ffa8cbeb863 - <tracing_subscriber[c0eceff03426eead]::fmt::format::Writer>::write_fmt
   7:     0x7ffacf3460d3 - std::panicking::rust_panic_with_hook::h05ca8ac23cc77c65
   8:     0x7ffa8de87e84 - <rustc_middle[3a1ce97b5b0524ba]::ty::VariantFlags as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
   9:     0x7ffa8de82159 - <rustc_middle[3a1ce97b5b0524ba]::ty::VariantFlags as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
  10:     0x7ffa8df0b0f3 - rustc_middle[3a1ce97b5b0524ba]::dep_graph::dep_node::DEP_KIND_VARIANTS::panic_cold_explicit
  11:     0x7ffa8dee005e - rustc_middle[3a1ce97b5b0524ba]::util::bug::bug_fmt
  12:     0x7ffa8dedf6fd - rustc_middle[3a1ce97b5b0524ba]::ty::util::is_doc_notable_trait
  13:     0x7ffa8dedf6ca - rustc_middle[3a1ce97b5b0524ba]::ty::util::is_doc_notable_trait
  14:     0x7ffa8dedff82 - rustc_middle[3a1ce97b5b0524ba]::util::bug::bug_fmt
  15:     0x7ffa88de11f5 - LLVMRustLinkerAdd
  16:     0x7ffa88e057a2 - <rustc_codegen_llvm[4b6651d80c2e5a32]::LlvmCodegenBackend as rustc_codegen_ssa[dba68bb7903231d2]::traits::backend::CodegenBackend>::link
  17:     0x7ffa88dec756 - <rustc_codegen_llvm[4b6651d80c2e5a32]::LlvmCodegenBackend as rustc_codegen_ssa[dba68bb7903231d2]::traits::backend::CodegenBackend>::join_codegen
  18:     0x7ffa88d9102b - <rustc_interface[6562ac5350621f0c]::queries::Linker>::link
  19:     0x7ffa88d685d0 - <rustc_middle[3a1ce97b5b0524ba]::ty::SymbolName as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
  20:     0x7ffa88d7385f - <rustc_middle[3a1ce97b5b0524ba]::ty::SymbolName as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
  21:     0x7ffa88d70bf8 - <rustc_middle[3a1ce97b5b0524ba]::ty::SymbolName as core[d4e1671815e8b4a5]::fmt::Debug>::fmt
  22:     0x7ffacf35803c - std::sys::pal::windows::thread::Thread::new::h51a32cdc9f29bad5
  23:     0x7ffb3fa6257d - BaseThreadInitThunk
  24:     0x7ffb40d6aa48 - RtlUserThreadStart

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: rustc 1.77.2 (25ef9e3d8 2024-04-09) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `hello-world` (bin "hello-world")
```

<!--
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 'copy LTO artifacts for 6qqtl33vkt97x99' panicked at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\compiler\rustc_codegen_ssa\src\back\write.rs:894:5:
assertion failed: module_config.emit_obj != EmitObj::None
stack backtrace:
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: rustc 1.77.2 (25ef9e3d8 2024-04-09) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread 'coordinator' panicked at compiler\rustc_middle\src\util\bug.rs:36:26:
/rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\compiler\rustc_codegen_ssa\src\back\write.rs:1588:29: worker thread panicked
stack backtrace:
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: rustc 1.77.2 (25ef9e3d8 2024-04-09) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread 'rustc' panicked at compiler\rustc_middle\src\util\bug.rs:36:26:
/rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\compiler\rustc_codegen_ssa\src\back\write.rs:1956:17: panic during codegen/LLVM phase
stack backtrace:
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: rustc 1.77.2 (25ef9e3d8 2024-04-09) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `hello-world` (bin "hello-world")
```

</p>
</details>