Skip to content

[ICE]: Reborrow trait usage during adjustment walk #156339

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024
#![feature(reborrow)]
use std::marker::Reborrow;
struct CustomMarker<'a> {
    ,
}
impl<'a> Reborrow for CustomMarker<'a> {
    fn foo(&self) {
        async { *self }
    }
}

original:

#![feature(reborrow)]
use std::marker::Reborrow;
struct CustomMarker<'a> {
    a: &'a str,
}
impl<'a> Reborrow for CustomMarker<'a> {
    fn foo(&self) {
        async { *self }
    }
}

fn main() {}

Version information

rustc 1.97.0-nightly (3e353d735 2026-05-08)
binary: rustc
commit-hash: 3e353d7353b0cd6fa4eefd5c882457cc2708184c
commit-date: 2026-05-08
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4

Possibly related line of code:

adjustment::Adjust::GenericReborrow(_reborrow) => {
// To build an expression as a place expression, it needs to be a field
// projection or deref at the outmost layer. So it is field projection or deref
// on an adjusted value. But this means that adjustment is applied on a
// subexpression that is not the final operand/rvalue for function call or
// assignment. This is a contradiction.
unreachable!("Reborrow trait usage during adjustment walk");
}
}
place_with_id = self.cat_expr_adjusted(expr, place_with_id, adjustment)?;
}
Ok(())

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2024

Program output

error: expected identifier, found `,`
 --> /tmp/icemaker_global_tempdir.oFRBp7C54n4y/rustc_testrunner_tmpdir_reporting.fkVxExmhXyfr/mvce.rs:4:5
  |
3 | struct CustomMarker<'a> {
  |        ------------ while parsing this struct
4 |     ,
  |     ^ expected identifier

error[E0407]: method `foo` is not a member of trait `Reborrow`
 --> /tmp/icemaker_global_tempdir.oFRBp7C54n4y/rustc_testrunner_tmpdir_reporting.fkVxExmhXyfr/mvce.rs:7:5
  |
7 | /     fn foo(&self) {
8 | |         async { *self }
9 | |     }
  | |_____^ not a member of trait `Reborrow`

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

error[E0308]: mismatched types
 --> /tmp/icemaker_global_tempdir.oFRBp7C54n4y/rustc_testrunner_tmpdir_reporting.fkVxExmhXyfr/mvce.rs:8:9
  |
7 |     fn foo(&self) {
  |                  - expected `()` because of default return type
8 |         async { *self }
  |         ^^^^^^^^^^^^^^^ expected `()`, found `async` block
  |
  = note:  expected unit type `()`
          found `async` block `{async block@/tmp/icemaker_global_tempdir.oFRBp7C54n4y/rustc_testrunner_tmpdir_reporting.fkVxExmhXyfr/mvce.rs:8:9: 8:14}`


thread 'rustc' (672003) panicked at /rustc-dev/3e353d7353b0cd6fa4eefd5c882457cc2708184c/compiler/rustc_hir_typeck/src/expr_use_visitor.rs:761:21:
internal error: entered unreachable code: Reborrow trait usage during adjustment walk
stack backtrace:
   0:     0x7ff79a274239 - <<std[db65628f2330fd11]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[b3c617e8375f9bd0]::fmt::Display>::fmt
   1:     0x7ff79a81b788 - core[b3c617e8375f9bd0]::fmt::write
   2:     0x7ff79a28ac66 - <std[db65628f2330fd11]::sys::stdio::unix::Stderr as std[db65628f2330fd11]::io::Write>::write_fmt
   3:     0x7ff79a24a2de - std[db65628f2330fd11]::panicking::default_hook::{closure#0}
   4:     0x7ff79a2678f3 - std[db65628f2330fd11]::panicking::default_hook
   5:     0x7ff7991544d1 - std[db65628f2330fd11]::panicking::update_hook::<alloc[b10a1c065189447]::boxed::Box<rustc_driver_impl[1f444ccaa450aabc]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7ff79a267bd2 - std[db65628f2330fd11]::panicking::panic_with_hook
   7:     0x7ff79a24a3d4 - std[db65628f2330fd11]::panicking::panic_handler::{closure#0}
   8:     0x7ff79a2410b9 - std[db65628f2330fd11]::sys::backtrace::__rust_end_short_backtrace::<std[db65628f2330fd11]::panicking::panic_handler::{closure#0}, !>
   9:     0x7ff79a24be0d - __rustc[87b1f669d989e0ab]::rust_begin_unwind
  10:     0x7ff79732c50c - core[b3c617e8375f9bd0]::panicking::panic_fmt
  11:     0x7ff79b499bb4 - <rustc_hir_typeck[9cad0c0c71173555]::expr_use_visitor::ExprUseVisitor<&rustc_hir_typeck[9cad0c0c71173555]::fn_ctxt::FnCtxt, &mut rustc_hir_typeck[9cad0c0c71173555]::upvar::InferBorrowKind>>::walk_expr
  12:     0x7ff79b49745b - <rustc_hir_typeck[9cad0c0c71173555]::expr_use_visitor::ExprUseVisitor<&rustc_hir_typeck[9cad0c0c71173555]::fn_ctxt::FnCtxt, &mut rustc_hir_typeck[9cad0c0c71173555]::upvar::InferBorrowKind>>::consume_expr
  13:     0x7ff79b48e5f4 - <rustc_hir_typeck[9cad0c0c71173555]::fn_ctxt::FnCtxt>::analyze_closure
  14:     0x7ff79b1c1766 - <rustc_hir_typeck[9cad0c0c71173555]::upvar::InferBorrowKindVisitor as rustc_hir[c65a271b9a709ef4]::intravisit::Visitor>::visit_expr
  15:     0x7ff79b1c5f6a - rustc_hir_typeck[9cad0c0c71173555]::typeck_with_inspect::{closure#0}
  16:     0x7ff79b1c29b0 - rustc_query_impl[3b9ecabc2cca1a8f]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  17:     0x7ff79a96d6a6 - rustc_query_impl[3b9ecabc2cca1a8f]::execution::try_execute_query::<rustc_data_structures[4a3bb46d707d6722]::vec_cache::VecCache<rustc_span[749aae40fdac821d]::def_id::LocalDefId, rustc_middle[4a2cff3451d2bad5]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[4a2cff3451d2bad5]::dep_graph::graph::DepNodeIndex>, false>
  18:     0x7ff79a96cec3 - rustc_query_impl[3b9ecabc2cca1a8f]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  19:     0x7ff79b06de6c - <rustc_middle[4a2cff3451d2bad5]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[8b0e6ecb57128d52]::check_crate::{closure#1}>::{closure#0}
  20:     0x7ff79b06d85c - rustc_hir_analysis[8b0e6ecb57128d52]::check_crate
  21:     0x7ff79a96ede1 - rustc_interface[232b63f46aa35c0e]::passes::analysis
  22:     0x7ff79b9822c9 - rustc_query_impl[3b9ecabc2cca1a8f]::execution::try_execute_query::<rustc_middle[4a2cff3451d2bad5]::query::caches::SingleCache<rustc_middle[4a2cff3451d2bad5]::query::erase::ErasedData<[u8; 0usize]>>, false>
  23:     0x7ff79b981f33 - rustc_query_impl[3b9ecabc2cca1a8f]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7ff79b9c765b - rustc_interface[232b63f46aa35c0e]::interface::run_compiler::<(), rustc_driver_impl[1f444ccaa450aabc]::run_compiler::{closure#0}>::{closure#1}
  25:     0x7ff79b975c3e - std[db65628f2330fd11]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[232b63f46aa35c0e]::util::run_in_thread_with_globals<rustc_interface[232b63f46aa35c0e]::util::run_in_thread_pool_with_globals<rustc_interface[232b63f46aa35c0e]::interface::run_compiler<(), rustc_driver_impl[1f444ccaa450aabc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:     0x7ff79b97632d - <std[db65628f2330fd11]::thread::lifecycle::spawn_unchecked<rustc_interface[232b63f46aa35c0e]::util::run_in_thread_with_globals<rustc_interface[232b63f46aa35c0e]::util::run_in_thread_pool_with_globals<rustc_interface[232b63f46aa35c0e]::interface::run_compiler<(), rustc_driver_impl[1f444ccaa450aabc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b3c617e8375f9bd0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7ff79b97712c - <std[db65628f2330fd11]::sys::thread::unix::Thread>::new::thread_start
  28:     0x7ff7954a597a - <unknown>
  29:     0x7ff7955292bc - <unknown>
  30:                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.97.0-nightly (3e353d735 2026-05-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck_root] type-checking `<impl at /tmp/icemaker_global_tempdir.oFRBp7C54n4y/rustc_testrunner_tmpdir_reporting.fkVxExmhXyfr/mvce.rs:6:1: 6:39>::foo`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0308, E0407, E0601.
For more information about an error, try `rustc --explain E0308`.

@rustbot label +F-reborrow

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