Repository: rust
Issue: rustc crashing when using calculated default value
Labels: I-ICE,T-compiler,C-bug,F-generic_const_exprs,S-bug-has-test,requires-incomplete-features

### Code

```Rust
#![allow(non_camel_case_types)]
#![feature(generic_const_exprs)]
#![feature(specialization)]

const DEFAULT_SMALL_VEC_INLINE_CAPACITY: usize = std::mem::size_of::<usize>() * 8;

pub const fn tiny_vec_cap<T>() -> usize {
	return (DEFAULT_SMALL_VEC_INLINE_CAPACITY - 1) / std::mem::size_of::<T>()
}

pub struct TinyVec<T, const N: usize = {tiny_vec_cap::<T>()}>
	where [
		();
		(N * std::mem::size_of::<T>())
		- std::mem::size_of::<std::ptr::NonNull<T>>()
		- std::mem::size_of::<isize>()
	]: ,
{
	data: isize //TinyVecData<T, N>,
}

pub fn main() {
	let t = TinyVec::<u8>::new();
}
```


### Meta
`rustc --version --verbose`:
```
rustc 1.74.1-nightly (a28077b28 2023-12-04) (built from a source tarball)
binary: rustc
commit-hash: a28077b28a02b92985b3a3faecf92813155f1ea1
commit-date: 2023-12-04
host: x86_64-unknown-linux-gnu
release: 1.74.1-nightly
LLVM version: 17.0.4
```

### Error output

```
<output>
```

<!--
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 /home/spock/prog/rustup/rustc-1.74.1-src/compiler/rustc_errors/src/lib.rs:1651:9:
Box<dyn Any>
stack backtrace:
   0:     0x7f82b1d9fc25 - std::backtrace::Backtrace::create::h2db78dee7af9fe5a
   1:     0x7f82b1d9fb60 - std::backtrace::Backtrace::force_capture::heb762e8f8269c2cf
   2:     0x7f82b2a2a47e - std[bdfad7d95fc3ce0d]::panicking::update_hook::<alloc[c67d041b9bf1b3b1]::boxed::Box<rustc_driver_impl[10f2b04f264bf4c0]::install_ice_hook::{closure#0}>>::{closure#0}
   3:     0x7f82b1ddfcad - std::panicking::rust_panic_with_hook::h4f534fdcbf3ca2ab
   4:     0x7f82b845eb96 - std[bdfad7d95fc3ce0d]::panicking::begin_panic::<rustc_errors[f611e1cb4186356a]::ExplicitBug>::{closure#0}
   5:     0x7f82b845e8b6 - std[bdfad7d95fc3ce0d]::sys_common::backtrace::__rust_end_short_backtrace::<std[bdfad7d95fc3ce0d]::panicking::begin_panic<rustc_errors[f611e1cb4186356a]::ExplicitBug>::{closure#0}, !>
   6:     0x7f82b28e63d6 - std[bdfad7d95fc3ce0d]::panicking::begin_panic::<rustc_errors[f611e1cb4186356a]::ExplicitBug>
   7:     0x7f82b83ee8d7 - <rustc_errors[f611e1cb4186356a]::HandlerInner>::bug::<alloc[c67d041b9bf1b3b1]::string::String>
   8:     0x7f82b83ee6b9 - <rustc_errors[f611e1cb4186356a]::Handler>::bug::<alloc[c67d041b9bf1b3b1]::string::String>
   9:     0x7f82b83c43a7 - rustc_middle[44eb6a75cf518d6b]::util::bug::opt_span_bug_fmt::<rustc_span[4535af8233016efb]::span_encoding::Span>::{closure#0}
  10:     0x7f82b83c043c - rustc_middle[44eb6a75cf518d6b]::ty::context::tls::with_opt::<rustc_middle[44eb6a75cf518d6b]::util::bug::opt_span_bug_fmt<rustc_span[4535af8233016efb]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  11:     0x7f82b83c00f8 - rustc_middle[44eb6a75cf518d6b]::ty::context::tls::with_context_opt::<rustc_middle[44eb6a75cf518d6b]::ty::context::tls::with_opt<rustc_middle[44eb6a75cf518d6b]::util::bug::opt_span_bug_fmt<rustc_span[4535af8233016efb]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  12:     0x7f82b28df7a2 - rustc_middle[44eb6a75cf518d6b]::util::bug::bug_fmt
  13:     0x7f82b28e02de - <rustc_middle[44eb6a75cf518d6b]::ty::generic_args::ArgFolder>::const_param_out_of_range
  14:     0x7f82b842c07a - <rustc_middle[44eb6a75cf518d6b]::ty::generic_args::ArgFolder as rustc_type_ir[593b847924ce7199]::fold::TypeFolder<rustc_middle[44eb6a75cf518d6b]::ty::context::TyCtxt>>::fold_const
  15:     0x7f82b84a2173 - <&rustc_middle[44eb6a75cf518d6b]::ty::list::List<rustc_middle[44eb6a75cf518d6b]::ty::generic_args::GenericArg> as rustc_type_ir[593b847924ce7199]::fold::TypeFoldable<rustc_middle[44eb6a75cf518d6b]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[44eb6a75cf518d6b]::ty::generic_args::ArgFolder>
  16:     0x7f82b84a74f7 - <rustc_middle[44eb6a75cf518d6b]::ty::consts::Const as rustc_type_ir[593b847924ce7199]::fold::TypeSuperFoldable<rustc_middle[44eb6a75cf518d6b]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_middle[44eb6a75cf518d6b]::ty::generic_args::ArgFolder>
  17:     0x7f82b8374348 - <rustc_middle[44eb6a75cf518d6b]::ty::Ty as rustc_type_ir[593b847924ce7199]::fold::TypeSuperFoldable<rustc_middle[44eb6a75cf518d6b]::ty::context::TyCtxt>>::try_super_fold_with::<rustc_middle[44eb6a75cf518d6b]::ty::generic_args::ArgFolder>
  18:     0x7f82b8382c81 - <rustc_middle[44eb6a75cf518d6b]::ty::ClauseKind as rustc_type_ir[593b847924ce7199]::fold::TypeFoldable<rustc_middle[44eb6a75cf518d6b]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[44eb6a75cf518d6b]::ty::generic_args::ArgFolder>
  19:     0x7f82b8383b86 - <rustc_middle[44eb6a75cf518d6b]::ty::PredicateKind as rustc_type_ir[593b847924ce7199]::fold::TypeFoldable<rustc_middle[44eb6a75cf518d6b]::ty::context::TyCtxt>>::try_fold_with::<rustc_middle[44eb6a75cf518d6b]::ty::generic_args::ArgFolder>
  20:     0x7f82b838d214 - <core[f6e056eb5cd9dbcb]::iter::adapters::map::Map<core[f6e056eb5cd9dbcb]::slice::iter::Iter<(rustc_middle[44eb6a75cf518d6b]::ty::Clause, rustc_span[4535af8233016efb]::span_encoding::Span)>, <rustc_middle[44eb6a75cf518d6b]::ty::generics::GenericPredicates>::instantiate_into::{closure#0}> as core[f6e056eb5cd9dbcb]::iter::traits::iterator::Iterator>::fold::<(), core[f6e056eb5cd9dbcb]::iter::traits::iterator::Iterator::for_each::call<rustc_middle[44eb6a75cf518d6b]::ty::Clause, <alloc[c67d041b9bf1b3b1]::vec::Vec<rustc_middle[44eb6a75cf518d6b]::ty::Clause>>::extend_trusted<core[f6e056eb5cd9dbcb]::iter::adapters::map::Map<core[f6e056eb5cd9dbcb]::slice::iter::Iter<(rustc_middle[44eb6a75cf518d6b]::ty::Clause, rustc_span[4535af8233016efb]::span_encoding::Span)>, <rustc_middle[44eb6a75cf518d6b]::ty::generics::GenericPredicates>::instantiate_into::{closure#0}>>::{closure#0}>::{closure#0}>
  21:     0x7f82b83ce85b - <rustc_middle[44eb6a75cf518d6b]::ty::generics::GenericPredicates>::instantiate_into
  22:     0x7f82b83c17c7 - <rustc_middle[44eb6a75cf518d6b]::ty::generics::GenericPredicates>::instantiate
  23:     0x7f82b80cf3ad - <rustc_trait_selection[3acff8e3b121b18f]::traits::wf::WfPredicates>::nominal_obligations
  24:     0x7f82b80cddb3 - <rustc_trait_selection[3acff8e3b121b18f]::traits::wf::WfPredicates>::compute
  25:     0x7f82b80ca65e - rustc_trait_selection[3acff8e3b121b18f]::traits::wf::obligations
  26:     0x7f82b8073eea - <rustc_trait_selection[3acff8e3b121b18f]::traits::fulfill::FulfillProcessor as rustc_data_structures[787a2ef21f270cd3]::obligation_forest::ObligationProcessor>::process_obligation
  27:     0x7f82b80625d8 - <rustc_data_structures[787a2ef21f270cd3]::obligation_forest::ObligationForest<rustc_trait_selection[3acff8e3b121b18f]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[3acff8e3b121b18f]::traits::fulfill::FulfillProcessor>
  28:     0x7f82b8071e56 - <rustc_trait_selection[3acff8e3b121b18f]::traits::fulfill::FulfillmentContext as rustc_infer[1566c839cb6cf411]::traits::engine::TraitEngine>::select_where_possible
  29:     0x7f82b80c7848 - <rustc_infer[1566c839cb6cf411]::infer::at::At as rustc_trait_selection[3acff8e3b121b18f]::traits::project::NormalizeExt>::deeply_normalize::<rustc_middle[44eb6a75cf518d6b]::ty::Ty>
  30:     0x7f82b7ff7d97 - <rustc_trait_selection[3acff8e3b121b18f]::traits::engine::ObligationCtxt>::assumed_wf_types
  31:     0x7f82b7ff7a9d - <rustc_trait_selection[3acff8e3b121b18f]::traits::engine::ObligationCtxt>::assumed_wf_types_and_report_errors
  32:     0x7f82b65eb056 - rustc_hir_analysis[e1e2c29a20eed8d7]::check::wfcheck::check_item_fn
  33:     0x7f82b65e6859 - rustc_hir_analysis[e1e2c29a20eed8d7]::check::wfcheck::check_well_formed
  34:     0x7f82b73c216c - rustc_query_impl[574f24497ced2294]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[574f24497ced2294]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[44eb6a75cf518d6b]::query::erase::Erased<[u8; 0usize]>>
  35:     0x7f82b74f518c - <rustc_query_impl[574f24497ced2294]::query_impl::check_well_formed::dynamic_query::{closure#2} as core[f6e056eb5cd9dbcb]::ops::function::FnOnce<(rustc_middle[44eb6a75cf518d6b]::ty::context::TyCtxt, rustc_hir[bdde3aae30964e4]::hir_id::OwnerId)>>::call_once
  36:     0x7f82b761a515 - rustc_query_system[1741f7a965137d1c]::query::plumbing::try_execute_query::<rustc_query_impl[574f24497ced2294]::DynamicConfig<rustc_query_system[1741f7a965137d1c]::query::caches::VecCache<rustc_hir[bdde3aae30964e4]::hir_id::OwnerId, rustc_middle[44eb6a75cf518d6b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[574f24497ced2294]::plumbing::QueryCtxt, false>
  37:     0x7f82b741a10d - rustc_query_impl[574f24497ced2294]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  38:     0x7f82b66e2578 - std[bdfad7d95fc3ce0d]::panicking::try::<(), core[f6e056eb5cd9dbcb]::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures[787a2ef21f270cd3]::sync::parallel::disabled::par_for_each_in<&[rustc_hir[bdde3aae30964e4]::hir::ImplItemId], <rustc_middle[44eb6a75cf518d6b]::hir::ModuleItems>::par_impl_items<rustc_hir_analysis[e1e2c29a20eed8d7]::check::wfcheck::check_mod_type_wf::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>>
  39:     0x7f82b6703c99 - <rustc_data_structures[787a2ef21f270cd3]::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures[787a2ef21f270cd3]::sync::parallel::disabled::par_for_each_in<&[rustc_hir[bdde3aae30964e4]::hir::ItemId], <rustc_middle[44eb6a75cf518d6b]::hir::ModuleItems>::par_items<rustc_hir_analysis[e1e2c29a20eed8d7]::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  40:     0x7f82b65ed57e - rustc_hir_analysis[e1e2c29a20eed8d7]::check::wfcheck::check_mod_type_wf
  41:     0x7f82b73c215c - rustc_query_impl[574f24497ced2294]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[574f24497ced2294]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[44eb6a75cf518d6b]::query::erase::Erased<[u8; 0usize]>>
  42:     0x7f82b74f50fc - <rustc_query_impl[574f24497ced2294]::query_impl::check_mod_type_wf::dynamic_query::{closure#2} as core[f6e056eb5cd9dbcb]::ops::function::FnOnce<(rustc_middle[44eb6a75cf518d6b]::ty::context::TyCtxt, rustc_span[4535af8233016efb]::def_id::LocalModDefId)>>::call_once
  43:     0x7f82b75e4d45 - rustc_query_system[1741f7a965137d1c]::query::plumbing::try_execute_query::<rustc_query_impl[574f24497ced2294]::DynamicConfig<rustc_query_system[1741f7a965137d1c]::query::caches::DefaultCache<rustc_span[4535af8233016efb]::def_id::LocalModDefId, rustc_middle[44eb6a75cf518d6b]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[574f24497ced2294]::plumbing::QueryCtxt, false>
  44:     0x7f82b740826d - rustc_query_impl[574f24497ced2294]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  45:     0x7f82b6703d7c - <rustc_data_structures[787a2ef21f270cd3]::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures[787a2ef21f270cd3]::sync::parallel::disabled::par_for_each_in<&[rustc_hir[bdde3aae30964e4]::hir_id::OwnerId], <rustc_middle[44eb6a75cf518d6b]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[e1e2c29a20eed8d7]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  46:     0x7f82b6673fde - rustc_hir_analysis[e1e2c29a20eed8d7]::check_crate
  47:     0x7f82b2bdfa00 - rustc_interface[ddf32e056eafbd1a]::passes::analysis
  48:     0x7f82b73c491a - rustc_query_impl[574f24497ced2294]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[574f24497ced2294]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[44eb6a75cf518d6b]::query::erase::Erased<[u8; 1usize]>>
  49:     0x7f82b7599cb8 - <rustc_query_impl[574f24497ced2294]::query_impl::analysis::dynamic_query::{closure#2} as core[f6e056eb5cd9dbcb]::ops::function::FnOnce<(rustc_middle[44eb6a75cf518d6b]::ty::context::TyCtxt, ())>>::call_once
  50:     0x7f82b75bcfdb - rustc_query_system[1741f7a965137d1c]::query::plumbing::try_execute_query::<rustc_query_impl[574f24497ced2294]::DynamicConfig<rustc_query_system[1741f7a965137d1c]::query::caches::SingleCache<rustc_middle[44eb6a75cf518d6b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[574f24497ced2294]::plumbing::QueryCtxt, false>
  51:     0x7f82b73f68f3 - rustc_query_impl[574f24497ced2294]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  52:     0x7f82b2a39362 - <rustc_middle[44eb6a75cf518d6b]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[10f2b04f264bf4c0]::run_compiler::{closure#1}::{closure#2}::{closure#6}, core[f6e056eb5cd9dbcb]::result::Result<(), rustc_span[4535af8233016efb]::ErrorGuaranteed>>
  53:     0x7f82b2a49811 - rustc_span[4535af8233016efb]::set_source_map::<core[f6e056eb5cd9dbcb]::result::Result<(), rustc_span[4535af8233016efb]::ErrorGuaranteed>, rustc_interface[ddf32e056eafbd1a]::interface::run_compiler<core[f6e056eb5cd9dbcb]::result::Result<(), rustc_span[4535af8233016efb]::ErrorGuaranteed>, rustc_driver_impl[10f2b04f264bf4c0]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  54:     0x7f82b2a29433 - std[bdfad7d95fc3ce0d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ddf32e056eafbd1a]::util::run_in_thread_with_globals<rustc_interface[ddf32e056eafbd1a]::interface::run_compiler<core[f6e056eb5cd9dbcb]::result::Result<(), rustc_span[4535af8233016efb]::ErrorGuaranteed>, rustc_driver_impl[10f2b04f264bf4c0]::run_compiler::{closure#1}>::{closure#0}, core[f6e056eb5cd9dbcb]::result::Result<(), rustc_span[4535af8233016efb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f6e056eb5cd9dbcb]::result::Result<(), rustc_span[4535af8233016efb]::ErrorGuaranteed>>
  55:     0x7f82b2a2a83b - <<std[bdfad7d95fc3ce0d]::thread::Builder>::spawn_unchecked_<rustc_interface[ddf32e056eafbd1a]::util::run_in_thread_with_globals<rustc_interface[ddf32e056eafbd1a]::interface::run_compiler<core[f6e056eb5cd9dbcb]::result::Result<(), rustc_span[4535af8233016efb]::ErrorGuaranteed>, rustc_driver_impl[10f2b04f264bf4c0]::run_compiler::{closure#1}>::{closure#0}, core[f6e056eb5cd9dbcb]::result::Result<(), rustc_span[4535af8233016efb]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f6e056eb5cd9dbcb]::result::Result<(), rustc_span[4535af8233016efb]::ErrorGuaranteed>>::{closure#1} as core[f6e056eb5cd9dbcb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  56:     0x7f82b1d912b5 - std::sys::unix::thread::Thread::new::thread_start::hd48d5955fb04426d
  57:     0x7f82b1ad7609 - start_thread
                               at /build/glibc-wuryBv/glibc-2.31/nptl/pthread_create.c:477:8
  58:     0x7f82b1c17353 - clone
                               at /build/glibc-wuryBv/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  59:                0x0 - <unknown>


rustc version: 1.74.1-nightly (a28077b28 2023-12-04) (built from a source tarball)
platform: x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `test_new` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
```

</p>
</details>