Repository: rust
Issue: ICE: `offset of unsized field (type dyn [Binder(Trait(std::fmt::Debug), [])] + '{erased}) cannot be computed statically`
Labels: I-ICE,T-compiler,C-bug,F-generic_const_exprs,S-has-mcve,S-bug-has-test,requires-incomplete-features

<!--
[31mICE[0m: Rustc ./a.rs '-Zunstable-options --edition=2024 -ooutputfile -Zdump-mir-dir=dir' 'thread 'rustc' panicked at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/compiler/rustc_target/src/abi/mod.rs:272:13: 'offset of unsized field (type dyn [Binder(Trait(std::fmt::Debug), [])] + '{erased}) cannot be computed statically'', 'thread 'rustc' panicked at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/compiler/rustc_target/src/abi/mod.rs:272:13: 'offset of unsized field (type dyn [Binder(Trait(std::fmt::Debug), [])] + '{erased}) cannot be computed statically''
File: /tmp/im/a.rs
-->

auto-reduced (treereduce-rust):
````rust
#![feature(generic_const_exprs)]

use core::fmt::Debug;

struct Inline<T>
where
    [(); std::mem::offset_of!((T,), 0)]:,
{
    ,
}

fn main() {
    let dst = Inline::<dyn Debug>::new(0); // BANG!
}


````

original:
````rust
#![feature(generic_const_exprs)]

use core::fmt::Debug;

struct Inline<T>
where
    [(); std::mem::offset_of!((T,), 0)]:,
{
    _phantom: PhantomData<T>,
}

fn main() {
    let dst = Inline::<dyn Debug>::new(0); // BANG!
}

````

Version information
````
rustc 1.80.0-nightly (8c4db851a 2024-05-28)
binary: rustc
commit-hash: 8c4db851a7bb64173832e6602638204ebbd373a8
commit-date: 2024-05-28
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

````

Command:
`/home/matthias/.rustup/toolchains/master/bin/rustc -Zunstable-options --edition=2024`

<!--
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: expected identifier, found `,`
 --> /tmp/icemaker_global_tempdir.iDOfR0adcfuD/rustc_testrunner_tmpdir_reporting.mdebWGeOXZOg/mvce.rs:9:5
  |
5 | struct Inline<T>
  |        ------ while parsing this struct
...
9 |     ,
  |     ^ expected identifier

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.iDOfR0adcfuD/rustc_testrunner_tmpdir_reporting.mdebWGeOXZOg/mvce.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0392]: type parameter `T` is never used
 --> /tmp/icemaker_global_tempdir.iDOfR0adcfuD/rustc_testrunner_tmpdir_reporting.mdebWGeOXZOg/mvce.rs:5:15
  |
5 | struct Inline<T>
  |               ^ unused type parameter
  |
  = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
  = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead

error[E0599]: no function or associated item named `new` found for struct `Inline` in the current scope
  --> /tmp/icemaker_global_tempdir.iDOfR0adcfuD/rustc_testrunner_tmpdir_reporting.mdebWGeOXZOg/mvce.rs:13:36
   |
5  | struct Inline<T>
   | ---------------- function or associated item `new` not found for this struct
...
13 |     let dst = Inline::<dyn Debug>::new(0); // BANG!
   |                                    ^^^ function or associated item not found in `Inline<dyn Debug>`

thread 'rustc' panicked at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/compiler/rustc_target/src/abi/mod.rs:272:13:
offset of unsized field (type dyn [Binder(Trait(std::fmt::Debug), [])] + '{erased}) cannot be computed statically
stack backtrace:
   0:     0x7ccc20196c65 - std::backtrace_rs::backtrace::libunwind::trace::h4d238c11cc7cd154
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7ccc20196c65 - std::backtrace_rs::backtrace::trace_unsynchronized::ha3df86955de0c7a6
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ccc20196c65 - std::sys_common::backtrace::_print_fmt::h23c469977983602f
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7ccc20196c65 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3ac6b603adc323a2
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7ccc201e76ab - core::fmt::rt::Argument::fmt::hdb449a86ba9bc938
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/core/src/fmt/rt.rs:165:63
   5:     0x7ccc201e76ab - core::fmt::write::hd2ddb8e7142b3c86
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/core/src/fmt/mod.rs:1168:21
   6:     0x7ccc2018b9ef - std::io::Write::write_fmt::hff992fce555b2195
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/io/mod.rs:1835:15
   7:     0x7ccc20196a3e - std::sys_common::backtrace::_print::h0ea9e1a90e98347b
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7ccc20196a3e - std::sys_common::backtrace::print::h74f9aa287ae4508b
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7ccc20199479 - std::panicking::default_hook::{{closure}}::h76d036e18731015d
  10:     0x7ccc2019921a - std::panicking::default_hook::h92f7dd3f0bb6bca4
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/panicking.rs:298:9
  11:     0x7ccc1c92dba0 - std[f8e7fb6155234cdc]::panicking::update_hook::<alloc[131c2bc553f8abcd]::boxed::Box<rustc_driver_impl[c954b14e48c55067]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7ccc20199bab - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h0c387ae443a27093
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/alloc/src/boxed.rs:2077:9
  13:     0x7ccc20199bab - std::panicking::rust_panic_with_hook::h997724c171ea4379
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/panicking.rs:799:13
  14:     0x7ccc20199924 - std::panicking::begin_panic_handler::{{closure}}::hcd4878c97c6ba2dd
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/panicking.rs:664:13
  15:     0x7ccc20197129 - std::sys_common::backtrace::__rust_end_short_backtrace::h17171f43285da353
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7ccc20199657 - rust_begin_unwind
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/panicking.rs:652:5
  17:     0x7ccc201e3c43 - core::panicking::panic_fmt::h75d0b9d62f2bc1e8
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/core/src/panicking.rs:72:14
  18:     0x7ccc1c898b3d - <rustc_target[678f303b8977fdf2]::abi::TyAndLayout<rustc_middle[a2b2892f2f577b38]::ty::Ty>>::offset_of_subfield::<rustc_const_eval[eb50b78a926245bf]::interpret::eval_context::InterpCx<rustc_const_eval[eb50b78a926245bf]::const_eval::machine::CompileTimeInterpreter>, core[f96848fe7c912e6]::iter::adapters::copied::Copied<core[f96848fe7c912e6]::slice::iter::Iter<(rustc_target[678f303b8977fdf2]::abi::VariantIdx, rustc_target[678f303b8977fdf2]::abi::FieldIdx)>>>
  19:     0x7ccc1bec4dca - <rustc_const_eval[eb50b78a926245bf]::interpret::eval_context::InterpCx<rustc_const_eval[eb50b78a926245bf]::const_eval::machine::CompileTimeInterpreter>>::eval_rvalue_into_place
  20:     0x7ccc1be4a09c - rustc_const_eval[eb50b78a926245bf]::const_eval::eval_queries::eval_to_allocation_raw_provider
  21:     0x7ccc1e3785f6 - rustc_query_impl[15feac3724dfdbc5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[15feac3724dfdbc5]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 24usize]>>
  22:     0x7ccc1e377e19 - rustc_query_system[a696f26bcf6730e1]::query::plumbing::try_execute_query::<rustc_query_impl[15feac3724dfdbc5]::DynamicConfig<rustc_query_system[a696f26bcf6730e1]::query::caches::DefaultCache<rustc_middle[a2b2892f2f577b38]::ty::ParamEnvAnd<rustc_middle[a2b2892f2f577b38]::mir::interpret::GlobalId>, rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[15feac3724dfdbc5]::plumbing::QueryCtxt, false>
  23:     0x7ccc1e3779f6 - rustc_query_impl[15feac3724dfdbc5]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7ccc1eb01ef6 - rustc_middle[a2b2892f2f577b38]::query::plumbing::query_get_at::<rustc_query_system[a696f26bcf6730e1]::query::caches::DefaultCache<rustc_middle[a2b2892f2f577b38]::ty::ParamEnvAnd<rustc_middle[a2b2892f2f577b38]::mir::interpret::GlobalId>, rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 24usize]>>>
  25:     0x7ccc1eb021b5 - rustc_const_eval[eb50b78a926245bf]::const_eval::valtrees::eval_to_valtree
  26:     0x7ccc1eb02149 - <rustc_const_eval[eb50b78a926245bf]::provide::{closure#0} as core[f96848fe7c912e6]::ops::function::FnOnce<(rustc_middle[a2b2892f2f577b38]::ty::context::TyCtxt, rustc_middle[a2b2892f2f577b38]::ty::ParamEnvAnd<rustc_middle[a2b2892f2f577b38]::mir::interpret::GlobalId>)>>::call_once
  27:     0x7ccc1eb02100 - rustc_query_impl[15feac3724dfdbc5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[15feac3724dfdbc5]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 24usize]>>
  28:     0x7ccc1eb020c1 - <rustc_query_impl[15feac3724dfdbc5]::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core[f96848fe7c912e6]::ops::function::FnOnce<(rustc_middle[a2b2892f2f577b38]::ty::context::TyCtxt, rustc_middle[a2b2892f2f577b38]::ty::ParamEnvAnd<rustc_middle[a2b2892f2f577b38]::mir::interpret::GlobalId>)>>::call_once
  29:     0x7ccc1e377ef4 - rustc_query_system[a696f26bcf6730e1]::query::plumbing::try_execute_query::<rustc_query_impl[15feac3724dfdbc5]::DynamicConfig<rustc_query_system[a696f26bcf6730e1]::query::caches::DefaultCache<rustc_middle[a2b2892f2f577b38]::ty::ParamEnvAnd<rustc_middle[a2b2892f2f577b38]::mir::interpret::GlobalId>, rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[15feac3724dfdbc5]::plumbing::QueryCtxt, false>
  30:     0x7ccc1e377820 - rustc_query_impl[15feac3724dfdbc5]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7ccc1e7d8271 - rustc_middle[a2b2892f2f577b38]::query::plumbing::query_get_at::<rustc_query_system[a696f26bcf6730e1]::query::caches::DefaultCache<rustc_middle[a2b2892f2f577b38]::ty::ParamEnvAnd<rustc_middle[a2b2892f2f577b38]::mir::interpret::GlobalId>, rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 24usize]>>>
  32:     0x7ccc1e7b4c33 - <rustc_middle[a2b2892f2f577b38]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
  33:     0x7ccc1e7b517e - <rustc_middle[a2b2892f2f577b38]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  34:     0x7ccc1cc8bed2 - <rustc_infer[79b642a8598597de]::infer::InferCtxt>::const_eval_resolve
  35:     0x7ccc1f608187 - rustc_trait_selection[40fbda06b434bec2]::traits::const_evaluatable::is_const_evaluatable.cold
  36:     0x7ccc1a8e99f6 - <rustc_trait_selection[40fbda06b434bec2]::traits::fulfill::FulfillProcessor as rustc_data_structures[af1e66d4cc57fb52]::obligation_forest::ObligationProcessor>::process_obligation
  37:     0x7ccc1de05ee3 - <rustc_data_structures[af1e66d4cc57fb52]::obligation_forest::ObligationForest<rustc_trait_selection[40fbda06b434bec2]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[40fbda06b434bec2]::traits::fulfill::FulfillProcessor>
  38:     0x7ccc1de054fb - <rustc_trait_selection[40fbda06b434bec2]::traits::fulfill::FulfillmentContext as rustc_infer[79b642a8598597de]::traits::engine::TraitEngine>::select_where_possible
  39:     0x7ccc1e7f37e0 - <rustc_hir_typeck[667b19700d0d687b]::fn_ctxt::FnCtxt>::check_decl
  40:     0x7ccc1e7f6407 - <rustc_hir_typeck[667b19700d0d687b]::fn_ctxt::FnCtxt>::check_block_with_expected
  41:     0x7ccc1e7fa5fa - <rustc_hir_typeck[667b19700d0d687b]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  42:     0x7ccc1e192d54 - rustc_hir_typeck[667b19700d0d687b]::check::check_fn
  43:     0x7ccc1e1884ec - rustc_hir_typeck[667b19700d0d687b]::typeck
  44:     0x7ccc1e187f51 - rustc_query_impl[15feac3724dfdbc5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[15feac3724dfdbc5]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 8usize]>>
  45:     0x7ccc1e054a6e - rustc_query_system[a696f26bcf6730e1]::query::plumbing::try_execute_query::<rustc_query_impl[15feac3724dfdbc5]::DynamicConfig<rustc_query_system[a696f26bcf6730e1]::query::caches::VecCache<rustc_span[8254473454f74006]::def_id::LocalDefId, rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[15feac3724dfdbc5]::plumbing::QueryCtxt, false>
  46:     0x7ccc1e053595 - rustc_query_impl[15feac3724dfdbc5]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  47:     0x7ccc1e0531cb - <rustc_middle[a2b2892f2f577b38]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[3017a44d0426b7dc]::check_crate::{closure#4}>::{closure#0}
  48:     0x7ccc1e051c80 - rustc_hir_analysis[3017a44d0426b7dc]::check_crate
  49:     0x7ccc1e784fbe - rustc_interface[fa3ac5f922d70623]::passes::analysis
  50:     0x7ccc1e784b1b - rustc_query_impl[15feac3724dfdbc5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[15feac3724dfdbc5]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 1usize]>>
  51:     0x7ccc1eb404e5 - rustc_query_system[a696f26bcf6730e1]::query::plumbing::try_execute_query::<rustc_query_impl[15feac3724dfdbc5]::DynamicConfig<rustc_query_system[a696f26bcf6730e1]::query::caches::SingleCache<rustc_middle[a2b2892f2f577b38]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[15feac3724dfdbc5]::plumbing::QueryCtxt, false>
  52:     0x7ccc1eb4024f - rustc_query_impl[15feac3724dfdbc5]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  53:     0x7ccc1e99219c - rustc_interface[fa3ac5f922d70623]::interface::run_compiler::<core[f96848fe7c912e6]::result::Result<(), rustc_span[8254473454f74006]::ErrorGuaranteed>, rustc_driver_impl[c954b14e48c55067]::run_compiler::{closure#0}>::{closure#1}
  54:     0x7ccc1e959c49 - std[f8e7fb6155234cdc]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[fa3ac5f922d70623]::util::run_in_thread_with_globals<rustc_interface[fa3ac5f922d70623]::util::run_in_thread_pool_with_globals<rustc_interface[fa3ac5f922d70623]::interface::run_compiler<core[f96848fe7c912e6]::result::Result<(), rustc_span[8254473454f74006]::ErrorGuaranteed>, rustc_driver_impl[c954b14e48c55067]::run_compiler::{closure#0}>::{closure#1}, core[f96848fe7c912e6]::result::Result<(), rustc_span[8254473454f74006]::ErrorGuaranteed>>::{closure#0}, core[f96848fe7c912e6]::result::Result<(), rustc_span[8254473454f74006]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f96848fe7c912e6]::result::Result<(), rustc_span[8254473454f74006]::ErrorGuaranteed>>
  55:     0x7ccc1e9599f2 - <<std[f8e7fb6155234cdc]::thread::Builder>::spawn_unchecked_<rustc_interface[fa3ac5f922d70623]::util::run_in_thread_with_globals<rustc_interface[fa3ac5f922d70623]::util::run_in_thread_pool_with_globals<rustc_interface[fa3ac5f922d70623]::interface::run_compiler<core[f96848fe7c912e6]::result::Result<(), rustc_span[8254473454f74006]::ErrorGuaranteed>, rustc_driver_impl[c954b14e48c55067]::run_compiler::{closure#0}>::{closure#1}, core[f96848fe7c912e6]::result::Result<(), rustc_span[8254473454f74006]::ErrorGuaranteed>>::{closure#0}, core[f96848fe7c912e6]::result::Result<(), rustc_span[8254473454f74006]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f96848fe7c912e6]::result::Result<(), rustc_span[8254473454f74006]::ErrorGuaranteed>>::{closure#2} as core[f96848fe7c912e6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  56:     0x7ccc201a3b9b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h92985bc629ea4743
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/alloc/src/boxed.rs:2063:9
  57:     0x7ccc201a3b9b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1c68b5b6b31624ec
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/alloc/src/boxed.rs:2063:9
  58:     0x7ccc201a3b9b - std::sys::pal::unix::thread::Thread::new::thread_start::h8466af519f9973b8
                               at /rustc/8c4db851a7bb64173832e6602638204ebbd373a8/library/std/src/sys/pal/unix/thread.rs:108:17
  59:     0x7ccc1ff401cf - <unknown>
  60:     0x7ccc1ffc16ec - <unknown>
  61:                0x0 - <unknown>

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 make sure that you have updated to the latest nightly

note: rustc 1.80.0-nightly (8c4db851a 2024-05-28) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unstable-options -Z dump-mir-dir=dir

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `Inline::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0392, E0599.
For more information about an error, try `rustc --explain E0392`.

```

</p>
</details>

<!--
query stack:
offset of unsized field (type dyn [Binder(Trait(std::fmt::Debug), [])] + '{erased}) cannot be computed statically
#0 [eval_to_allocation_raw] const-evaluating + checking `Inline::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant

-->
@rustbot label +F-generic_const_exprs