Repository: rust
Issue: ICE: `expected int of size 8, but got size 16`
Labels: I-ICE,T-compiler,C-bug,S-bug-has-test

<!--
[31mICE[0m: Rustc ./o.rs '' 'error: internal compiler error: /rustc/c4f7176501a7d3c19c230b8c9111b2d39142f83a/compiler/rustc_middle/src/ty/consts/int.rs:263:13: expected int of size 8, but got size 16', 'error: internal compiler error: /rustc/c4f7176501a7d3c19c230b8c9111b2d39142f83a/compiler/rustc_middle/src/ty/consts/int.rs:263:13: expected int of size 8, but got size 16'
File: /tmp/im/o.rs
-->

auto-reduced (treereduce-rust):
````rust
struct Struct<const N: i128>(pub [u8; N]);

pub fn function(value: Struct<3>) -> u8 {
    value.0[0]
}


````

original:
````rust
pub(in std::vec) struct Struct<const N: i128>(pub [u8; N]);

pub type Alias = Struct<2>;

pub fn function(value: Struct<3>) -> u8 {
    value.0[0]
}


````

Version information
````
rustc 1.83.0-nightly (c4f717650 2024-10-01)
binary: rustc
commit-hash: c4f7176501a7d3c19c230b8c9111b2d39142f83a
commit-date: 2024-10-01
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

````

Command:
`/home/matthias/.rustup/toolchains/master/bin/rustc `

<!--
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>Program output</strong></summary>
<p>

```
error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.3gYz1ILWhmcV/rustc_testrunner_tmpdir_reporting.d58vX2lbiZNF/mvce.rs:5:2
  |
5 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.3gYz1ILWhmcV/rustc_testrunner_tmpdir_reporting.d58vX2lbiZNF/mvce.rs`

error: the constant `N` is not of type `usize`
 --> /tmp/icemaker_global_tempdir.3gYz1ILWhmcV/rustc_testrunner_tmpdir_reporting.d58vX2lbiZNF/mvce.rs:1:34
  |
1 | struct Struct<const N: i128>(pub [u8; N]);
  |                                  ^^^^^^^ expected `usize`, found `i128`

error: internal compiler error: /rustc/c4f7176501a7d3c19c230b8c9111b2d39142f83a/compiler/rustc_middle/src/ty/consts/int.rs:263:13: expected int of size 8, but got size 16

thread 'rustc' panicked at /rustc/c4f7176501a7d3c19c230b8c9111b2d39142f83a/compiler/rustc_middle/src/ty/consts/int.rs:263:13:
Box<dyn Any>
stack backtrace:
   0:     0x77bdb52daeda - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::had0a4a07d444c243
   1:     0x77bdb5a033e6 - core::fmt::write::hfa03780471fd40a1
   2:     0x77bdb6bbd491 - std::io::Write::write_fmt::he88bb98b829c33b1
   3:     0x77bdb52dad32 - std::sys::backtrace::BacktraceLock::print::h1e8153a6bf47e7a5
   4:     0x77bdb52dd251 - std::panicking::default_hook::{{closure}}::h2d7a6dde612f1b16
   5:     0x77bdb52dd084 - std::panicking::default_hook::ha6ce9de3458bcdda
   6:     0x77bdb43a486f - std[c1d7bd3f58de7430]::panicking::update_hook::<alloc[29d5ad3c4a91d383]::boxed::Box<rustc_driver_impl[b3d9015aed309aa5]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x77bdb52dd968 - std::panicking::rust_panic_with_hook::haf1d2e00d64b82f1
   8:     0x77bdb43de321 - std[c1d7bd3f58de7430]::panicking::begin_panic::<rustc_errors[a2cc27f529684419]::ExplicitBug>::{closure#0}
   9:     0x77bdb43d13c6 - std[c1d7bd3f58de7430]::sys::backtrace::__rust_end_short_backtrace::<std[c1d7bd3f58de7430]::panicking::begin_panic<rustc_errors[a2cc27f529684419]::ExplicitBug>::{closure#0}, !>
  10:     0x77bdb43ccad9 - std[c1d7bd3f58de7430]::panicking::begin_panic::<rustc_errors[a2cc27f529684419]::ExplicitBug>
  11:     0x77bdb43e7bb1 - <rustc_errors[a2cc27f529684419]::diagnostic::BugAbort as rustc_errors[a2cc27f529684419]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x77bdb4a0ba54 - rustc_middle[99056c3c142edfd1]::util::bug::opt_span_bug_fmt::<rustc_span[fbdd09955dfcae25]::span_encoding::Span>::{closure#0}
  13:     0x77bdb49f17ca - rustc_middle[99056c3c142edfd1]::ty::context::tls::with_opt::<rustc_middle[99056c3c142edfd1]::util::bug::opt_span_bug_fmt<rustc_span[fbdd09955dfcae25]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x77bdb49f165b - rustc_middle[99056c3c142edfd1]::ty::context::tls::with_context_opt::<rustc_middle[99056c3c142edfd1]::ty::context::tls::with_opt<rustc_middle[99056c3c142edfd1]::util::bug::opt_span_bug_fmt<rustc_span[fbdd09955dfcae25]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x77bdb1fcce60 - rustc_middle[99056c3c142edfd1]::util::bug::bug_fmt
  16:     0x77bdb5f805ad - rustc_ty_utils[7eb78ab09d37383f]::layout::layout_of_uncached
  17:     0x77bdb5f6e6c6 - rustc_ty_utils[7eb78ab09d37383f]::layout::layout_of
  18:     0x77bdb5f6e651 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 16usize]>>
  19:     0x77bdb5f6d8cd - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::DefaultCache<rustc_middle[99056c3c142edfd1]::ty::ParamEnvAnd<rustc_middle[99056c3c142edfd1]::ty::Ty>, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  20:     0x77bdb5f6d567 - rustc_query_impl[a128c9efc091a24e]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  21:     0x77bdb5f6c962 - <core[d0cd706d8d014919]::iter::adapters::GenericShunt<core[d0cd706d8d014919]::iter::adapters::by_ref_sized::ByRefSized<core[d0cd706d8d014919]::iter::adapters::map::Map<core[d0cd706d8d014919]::slice::iter::Iter<rustc_middle[99056c3c142edfd1]::ty::VariantDef>, rustc_ty_utils[7eb78ab09d37383f]::layout::layout_of_uncached::{closure#13}>>, core[d0cd706d8d014919]::result::Result<core[d0cd706d8d014919]::convert::Infallible, &rustc_middle[99056c3c142edfd1]::ty::layout::LayoutError>> as core[d0cd706d8d014919]::iter::traits::iterator::Iterator>::next
  22:     0x77bdb5f73150 - rustc_ty_utils[7eb78ab09d37383f]::layout::layout_of_uncached
  23:     0x77bdb5f6e6c6 - rustc_ty_utils[7eb78ab09d37383f]::layout::layout_of
  24:     0x77bdb5f6e651 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::layout_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 16usize]>>
  25:     0x77bdb5f6d8cd - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::DefaultCache<rustc_middle[99056c3c142edfd1]::ty::ParamEnvAnd<rustc_middle[99056c3c142edfd1]::ty::Ty>, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 16usize]>>, false, true, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  26:     0x77bdb5f6d567 - rustc_query_impl[a128c9efc091a24e]::query_impl::layout_of::get_query_non_incr::__rust_end_short_backtrace
  27:     0x77bdb2fa578d - <rustc_mir_transform[72b720a2bb6a9bbb]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[72b720a2bb6a9bbb]::pass_manager::MirLint>::run_lint
  28:     0x77bdb5a06d0c - rustc_mir_transform[72b720a2bb6a9bbb]::run_analysis_to_runtime_passes
  29:     0x77bdb62bc48e - rustc_mir_transform[72b720a2bb6a9bbb]::mir_drops_elaborated_and_const_checked
  30:     0x77bdb62bbdd1 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 8usize]>>
  31:     0x77bdb5da94ba - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::VecCache<rustc_span[fbdd09955dfcae25]::def_id::LocalDefId, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  32:     0x77bdb5da8e65 - rustc_query_impl[a128c9efc091a24e]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  33:     0x77bdb5da30a4 - rustc_interface[89dec4b9d675c708]::passes::run_required_analyses
  34:     0x77bdb670f51e - rustc_interface[89dec4b9d675c708]::passes::analysis
  35:     0x77bdb670f4f1 - rustc_query_impl[a128c9efc091a24e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a128c9efc091a24e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>
  36:     0x77bdb689252e - rustc_query_system[a5b010e784c9cc4f]::query::plumbing::try_execute_query::<rustc_query_impl[a128c9efc091a24e]::DynamicConfig<rustc_query_system[a5b010e784c9cc4f]::query::caches::SingleCache<rustc_middle[99056c3c142edfd1]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[a128c9efc091a24e]::plumbing::QueryCtxt, false>
  37:     0x77bdb689220f - rustc_query_impl[a128c9efc091a24e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  38:     0x77bdb671f55e - rustc_interface[89dec4b9d675c708]::interface::run_compiler::<core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>, rustc_driver_impl[b3d9015aed309aa5]::run_compiler::{closure#0}>::{closure#1}
  39:     0x77bdb67ea350 - std[c1d7bd3f58de7430]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[89dec4b9d675c708]::util::run_in_thread_with_globals<rustc_interface[89dec4b9d675c708]::util::run_in_thread_pool_with_globals<rustc_interface[89dec4b9d675c708]::interface::run_compiler<core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>, rustc_driver_impl[b3d9015aed309aa5]::run_compiler::{closure#0}>::{closure#1}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>
  40:     0x77bdb67ea9ba - <<std[c1d7bd3f58de7430]::thread::Builder>::spawn_unchecked_<rustc_interface[89dec4b9d675c708]::util::run_in_thread_with_globals<rustc_interface[89dec4b9d675c708]::util::run_in_thread_pool_with_globals<rustc_interface[89dec4b9d675c708]::interface::run_compiler<core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>, rustc_driver_impl[b3d9015aed309aa5]::run_compiler::{closure#0}>::{closure#1}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[d0cd706d8d014919]::result::Result<(), rustc_span[fbdd09955dfcae25]::ErrorGuaranteed>>::{closure#1} as core[d0cd706d8d014919]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x77bdb67eadab - std::sys::pal::unix::thread::Thread::new::thread_start::h6a16a471557e53ce
  42:     0x77bdb7e5c39d - <unknown>
  43:     0x77bdb7ee149c - <unknown>
  44:                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: please make sure that you have updated to the latest nightly

note: rustc 1.83.0-nightly (c4f717650 2024-10-01) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [layout_of] computing layout of `[u8; 3]`
#1 [layout_of] computing layout of `Struct<3>`
end of query stack
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0601`.

```

</p>
</details>

<!--
query stack:
#0 [layout_of] computing layout of `[u8; 3]`
#1 [layout_of] computing layout of `Struct<3>`

-->