Repository: rust
Issue: ICE: gce: `fn_abi_of_instance(..) failed: Layout(Unknown([FlatTree; UnevaluatedConst { .. }: usize]))`
Labels: I-ICE,E-needs-test,T-compiler,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/
-->

### Code

```Rust
#![feature(generic_const_exprs)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
struct FlatTree;

#[derive(Copy, Clone)]
struct TreeLeaf;

#[derive(Copy, Clone)]
struct TreeNode<V, W>(V, W);

const fn const_concat<const A: usize, const B: usize>(_: [FlatTree; A], _: [FlatTree; B]) -> [FlatTree; A + B] {
    [FlatTree; A + B]
}

struct Builder<const N: usize, I> {
    ops: [FlatTree; N],
    builder: I,
}

fn create_node<const N: usize, const M: usize, A, B>(a: Builder<N, A>, b: Builder<M, B>) -> Builder<{ N + M + 1 }, TreeNode<A, B>> {
    Builder {
        ops: const_concat(const_concat::<N, M>(a.ops, b.ops), [FlatTree]),
        builder: TreeNode(a.builder, b.builder),
    }
}

const LEAF: Builder<1, TreeLeaf> = Builder {
    ops: [FlatTree],
    builder: TreeLeaf,
};

static INTERNAL_SIMPLE_BOOLEAN_TEMPLATES: &[fn()] = &[{
    fn eval() {
        create_node(LEAF, create_node(LEAF, LEAF));
    }

    eval
}];
```


### 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.76.0-nightly (9fad68599 2023-12-03)
binary: rustc
commit-hash: 9fad6859925b34f9a0b1af592a7839ccb1e71f60
commit-date: 2023-12-03
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5
```

### Error output

```
   Compiling minimal-rust v0.1.0 (/home/../workspace/repro/minimal-rust)
[..] (warnings removed)
error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:1043:21: `fn_abi_of_instance(const_concat::<{const expr}, 1>, [])` failed: Layout(Unknown([FlatTree; UnevaluatedConst { def: DefId(0:8 ~ minimal_rust[599e]::const_concat::{constant#2}), args: [(Add: 1_usize, 3_usize): usize, 1_usize] }: usize]))
  --> minimal-rust/src/lib.rs:11:1
   |
11 | const fn const_concat<const A: usize, const B: usize>(_: [FlatTree; A], _: [FlatTree; B]) -> [FlatTree; A + B] {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at /rustc/9fad6859925b34f9a0b1af592a7839ccb1e71f60/compiler/rustc_errors/src/lib.rs:995:33:
Box<dyn Any>


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/../workspace/repro/rustc-ice-2023-12-04T12_27_11-290639.txt` to your bug report

note: compiler flags: --crate-type lib -C opt-level=2 -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `minimal-rust` (lib) generated 6 warnings
error: could not compile `minimal-rust` (lib); 6 warnings emitted
```

<!--
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/9fad6859925b34f9a0b1af592a7839ccb1e71f60/compiler/rustc_errors/src/lib.rs:995:33:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::HandlerInner>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   2: <rustc_errors::Handler>::span_bug::<rustc_span::span_encoding::Span, alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::span_bug_fmt::<rustc_span::span_encoding::Span>
   7: <rustc_codegen_llvm::context::CodegenCx as rustc_middle::ty::layout::FnAbiOfHelpers>::handle_fn_abi_err
   8: <rustc_codegen_llvm::context::CodegenCx as rustc_middle::ty::layout::FnAbiOf>::fn_abi_of_instance::{closure#0}
   9: <rustc_codegen_llvm::context::CodegenCx as rustc_codegen_ssa::traits::declare::PreDefineMethods>::predefine_fn
  10: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  11: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  12: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  13: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  14: rustc_interface::passes::start_codegen
  15: <rustc_interface::queries::Queries>::codegen_and_build_linker
  16: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#0}
```

</p>
</details>