Skip to content

[ICE]: reborrow: size mismatch: compiler/rustc_const_eval/src/interpret/place.rs #158149

Description

@matthiaskrgr

Code

#![feature(const_block_items)]
#![feature(reborrow)]
use std::marker::CoerceShared;
struct MyMut<'a>(&'a u8);
struct MyRef<'a> {
    x: &'a (),
    y: &'a (),
}

impl<'a> CoerceShared<MyRef<'a>> for MyMut<'a> {}
const {
    let value = 1;
    foo(MyMut(&value));
}
const fn foo(x: MyRef) {}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.98.0-nightly (bc2112ed5 2026-06-18)
binary: rustc
commit-hash: bc2112ed56c99fa649e09ab3ab286afab3d9059a
commit-date: 2026-06-18
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.7

Error output

error: implementing `CoerceShared` does not allow multiple lifetimes or fields to be coerced
  --> a.rs:10:10
   |
10 | impl<'a> CoerceShared<MyRef<'a>> for MyMut<'a> {}
   |          ^^^^^^^^^^^^^^^^^^^^^^^

Backtrace

thread 'rustc' (1255357) panicked at /rustc-dev/bc2112ed56c99fa649e09ab3ab286afab3d9059a/compiler/rustc_const_eval/src/interpret/place.rs:936:17:
assertion `left == right` failed
  left: Size(8 bytes)
 right: Size(16 bytes)
stack backtrace:
   0:     0x7f38d19fd889 - <<std[9155b05baf46f0b5]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[b26e7c5dab710dcd]::fmt::Display>::fmt
   1:     0x7f38d200ebde - core[b26e7c5dab710dcd]::fmt::write
   2:     0x7f38d1a13cb6 - <std[9155b05baf46f0b5]::sys::stdio::unix::Stderr as std[9155b05baf46f0b5]::io::Write>::write_fmt
   3:     0x7f38d19d2b7e - std[9155b05baf46f0b5]::panicking::default_hook::{closure#0}
   4:     0x7f38d19f0573 - std[9155b05baf46f0b5]::panicking::default_hook
   5:     0x7f38d0a49fc1 - std[9155b05baf46f0b5]::panicking::update_hook::<alloc[4a86d35f348a3b04]::boxed::Box<rustc_driver_impl[b791fc15675dcea2]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f38d19f0852 - std[9155b05baf46f0b5]::panicking::panic_with_hook
   7:     0x7f38d19d2c42 - std[9155b05baf46f0b5]::panicking::panic_handler::{closure#0}
   8:     0x7f38d19c7169 - std[9155b05baf46f0b5]::sys::backtrace::__rust_end_short_backtrace::<std[9155b05baf46f0b5]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f38d19d46ad - __rustc[b4c4dac14d05b73]::rust_begin_unwind
  10:     0x7f38ce90455c - core[b26e7c5dab710dcd]::panicking::panic_fmt
  11:     0x7f38d040bbd3 - core[b26e7c5dab710dcd]::panicking::assert_failed_inner
  12:     0x7f38d0faf839 - core[b26e7c5dab710dcd]::panicking::assert_failed::<rustc_abi[c68f683fea65e658]::Size, rustc_abi[c68f683fea65e658]::Size>
  13:     0x7f38d2704b02 - <rustc_const_eval[a05529753b3711cc]::interpret::eval_context::InterpCx<rustc_const_eval[a05529753b3711cc]::const_eval::machine::CompileTimeMachine>>::copy_op_no_validate::<rustc_const_eval[a05529753b3711cc]::interpret::operand::OpTy, rustc_const_eval[a05529753b3711cc]::interpret::place::PlaceTy>
  14:     0x7f38d3040cc2 - <rustc_const_eval[a05529753b3711cc]::interpret::eval_context::InterpCx<rustc_const_eval[a05529753b3711cc]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  15:     0x7f38d300360d - rustc_const_eval[a05529753b3711cc]::const_eval::eval_queries::eval_to_allocation_raw_provider
  16:     0x7f38d3001c56 - rustc_query_impl[f814d044a8094e2a]::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
  17:     0x7f38d26d3970 - rustc_query_impl[f814d044a8094e2a]::execution::try_execute_query::<rustc_middle[cb7c4bb37f51aac1]::query::caches::DefaultCache<rustc_middle[cb7c4bb37f51aac1]::ty::PseudoCanonicalInput<rustc_middle[cb7c4bb37f51aac1]::mir::interpret::GlobalId>, rustc_middle[cb7c4bb37f51aac1]::query::erase::ErasedData<[u8; 24usize]>>, false>
  18:     0x7f38d26d3297 - rustc_query_impl[f814d044a8094e2a]::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
  19:     0x7f38d26d18ca - rustc_const_eval[a05529753b3711cc]::const_eval::eval_queries::eval_to_const_value_raw_provider
  20:     0x7f38d26d151e - rustc_query_impl[f814d044a8094e2a]::query_impl::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f38d26d37ac - rustc_query_impl[f814d044a8094e2a]::execution::try_execute_query::<rustc_middle[cb7c4bb37f51aac1]::query::caches::DefaultCache<rustc_middle[cb7c4bb37f51aac1]::ty::PseudoCanonicalInput<rustc_middle[cb7c4bb37f51aac1]::mir::interpret::GlobalId>, rustc_middle[cb7c4bb37f51aac1]::query::erase::ErasedData<[u8; 24usize]>>, false>
  22:     0x7f38d26d334f - rustc_query_impl[f814d044a8094e2a]::query_impl::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f38d26d23c5 - rustc_const_eval[a05529753b3711cc]::const_eval::eval_queries::eval_to_const_value_raw_provider
  24:     0x7f38d26d151e - rustc_query_impl[f814d044a8094e2a]::query_impl::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7f38d26d37ac - rustc_query_impl[f814d044a8094e2a]::execution::try_execute_query::<rustc_middle[cb7c4bb37f51aac1]::query::caches::DefaultCache<rustc_middle[cb7c4bb37f51aac1]::ty::PseudoCanonicalInput<rustc_middle[cb7c4bb37f51aac1]::mir::interpret::GlobalId>, rustc_middle[cb7c4bb37f51aac1]::query::erase::ErasedData<[u8; 24usize]>>, false>
  26:     0x7f38d26d334f - rustc_query_impl[f814d044a8094e2a]::query_impl::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f38d24a842a - <rustc_middle[cb7c4bb37f51aac1]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[f8649c0bc5b32aaa]::check_crate::{closure#1}>::{closure#0}
  28:     0x7f38d24a7a25 - rustc_hir_analysis[f8649c0bc5b32aaa]::check_crate
  29:     0x7f38d24a9d0c - rustc_interface[84e7048b04034882]::passes::analysis
  30:     0x7f38d317f906 - rustc_query_impl[f814d044a8094e2a]::execution::try_execute_query::<rustc_middle[cb7c4bb37f51aac1]::query::caches::SingleCache<rustc_middle[cb7c4bb37f51aac1]::query::erase::ErasedData<[u8; 0usize]>>, false>
  31:     0x7f38d317f5e9 - rustc_query_impl[f814d044a8094e2a]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7f38d3199c52 - rustc_interface[84e7048b04034882]::interface::run_compiler::<(), rustc_driver_impl[b791fc15675dcea2]::run_compiler::{closure#0}>::{closure#1}
  33:     0x7f38d31ceffa - std[9155b05baf46f0b5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[84e7048b04034882]::util::run_in_thread_with_globals<rustc_interface[84e7048b04034882]::util::run_in_thread_pool_with_globals<rustc_interface[84e7048b04034882]::interface::run_compiler<(), rustc_driver_impl[b791fc15675dcea2]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  34:     0x7f38d31cedad - <std[9155b05baf46f0b5]::thread::lifecycle::spawn_unchecked<rustc_interface[84e7048b04034882]::util::run_in_thread_with_globals<rustc_interface[84e7048b04034882]::util::run_in_thread_pool_with_globals<rustc_interface[84e7048b04034882]::interface::run_compiler<(), rustc_driver_impl[b791fc15675dcea2]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b26e7c5dab710dcd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f38d31c5290 - <std[9155b05baf46f0b5]::sys::thread::unix::Thread>::new::thread_start
  36:     0x7f38ccc981b9 - <unknown>
  37:     0x7f38ccd1d21c - <unknown>
  38:                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: please attach the file at `/tmp/IM/rustc-ice-2026-06-19T19_06_42-1255347.txt` to your bug report

note: rustc 1.98.0-nightly (bc2112ed5 2026-06-18) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `_`
#1 [eval_to_const_value_raw] simplifying constant for the type system `_`
#2 [eval_to_const_value_raw] simplifying constant for the type system `_`
#3 [analysis] running analysis passes on crate `a`
end of query stack
error: aborting due to 1 previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-const_block_items`#![feature(const_block_items)]`F-reborrow`#![feature(reborrow)]`; see #145612I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions