Skip to content

[ICE]: Reborrow causes entered unreachable code in expr_as_place. #156482

@theemathas

Description

@theemathas

Code

#![feature(reborrow)]

use std::marker::Reborrow;

struct Thing<'a>(&'a ());

impl<'a> Reborrow for Thing<'a> {}

fn foo(x: Thing<'_>) {
    let _: Thing<'_> = x;
}

Meta

Reproducible on the playground with version 1.97.0-nightly (2026-05-10 4b0c9d76ae7d387229ca)

Error output

thread 'rustc' (67) panicked at /rustc-dev/4b0c9d76ae7d387229caea55cfa73c280b08b8a7/compiler/rustc_mir_build/src/builder/expr/as_place.rs:597:17:
internal error: entered unreachable code
Backtrace

stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: <rustc_mir_build::builder::Builder>::expr_as_place
   4: <rustc_mir_build::builder::Builder>::expr_as_place
   5: <rustc_mir_build::builder::Builder>::lower_scrutinee
   6: <rustc_mir_build::builder::Builder>::ast_block_stmts
   7: <rustc_mir_build::builder::Builder>::ast_block
   8: <rustc_mir_build::builder::Builder>::expr_into_dest
   9: <rustc_mir_build::builder::Builder>::expr_into_dest
  10: rustc_mir_build::builder::build_mir_inner_impl
  11: rustc_mir_transform::mir_built
  12: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
  13: rustc_mir_build::check_unsafety::check_unsafety
  14: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 0]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
  15: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  16: rustc_interface::passes::analysis
  17: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
  18: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 `/playground/rustc-ice-2026-05-12T03_25_26-65.txt` to your bug report

note: rustc 1.97.0-nightly (4b0c9d76a 2026-05-10) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_built] building MIR for `foo`
#1 [check_unsafety] unsafety-checking `foo`
#2 [analysis] running analysis passes on crate `playground`
end of query stack
error: could not compile `playground` (lib)

Relevant code:

ExprKind::Reborrow { .. } => {
// FIXME(reborrow): it should currently be impossible to end up evaluating a
// Reborrow expression as a place. That might not in the future, but what this then
// evaluates to requires further thought.
unreachable!();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions