[ICE]: `expected region 'static to be of kind ReVar`

Open
#165,656 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
compilers

Research direction

Start with the minimized Rust example in the issue and the backtrace, which points to GatherBorrows::gather_reborrows during MIR borrow checking. Reproduce the ICE with the reported nightly compiler, then trace how reborrow regions are handled in the borrow checker. Done when the example reports a compiler diagnostic instead of panicking and a regression test covers it.

Written by the indexing model from the issue text.

Description

C-bug F-reborrow I-ICE T-compiler
Code
#![feature(reborrow)]
use std::marker::Reborrow;

struct CustomMarker<'a> {
    x: &'a str,
}
struct CustomMarkerTwo<'a> {
    x: CustomMarker<'static>,
    y: &'a u64,
}

impl<'a> Reborrow for CustomMarker<'a> {}
impl<'a> Reborrow for CustomMarkerTwo<'a> {}

fn reborrow(_: CustomMarkerTwo) {
    let a;
    let a = CustomMarkerTwo { x: a, y: &0 };
    reborrow(a)
}

fn main() {}
Meta

rustc --version --verbose:

rustc 1.102.0-nightly (1a4d65fa9 2026-11-08)
binary: rustc
commit-hash: 1a4d65fa9d3ff3990d766c52e741c7027ffa4fc6
commit-date: 2026-11-08
host: x86_64-unknown-linux-gnu
release: 1.102.0-nightly
LLVM version: 23.1.5
Error output
`--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

warning: function cannot return without recursing
  --> code.rs:15:1
   |
15 | fn reborrow(_: CustomMarkerTwo) {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
...
18 |     reborrow(a)
   |     ----------- recursive call site
   |
   = help: a `loop` may express intention better if this is on purpose
   = note: `#[warn(unconditional_recursion)]` on by default

Backtrace

thread 'rustc' (894146) panicked at /rustc-dev/1a4d65fa9d3ff3990d766c52e741c7027ffa4fc6/compiler/rustc_type_ir/src/sty/mod.rs:192:18:
expected region 'static to be of kind ReVar
stack backtrace:
   0:     0x7fd0d7fb66b6 - <<std[1c3b28271551a578]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7deae0c0451d2349]::fmt::Display>::fmt
   1:     0x7fd0d860cd0f - core[7deae0c0451d2349]::fmt::write
   2:     0x7fd0d7fcb26c - <std[1c3b28271551a578]::sys::stdio::unix::Stderr as core[7deae0c0451d2349]::io::write::Write>::write_fmt
   3:     0x7fd0d7f8779a - std[1c3b28271551a578]::panicking::default_hook::{closure#0}
   4:     0x7fd0d7faa013 - std[1c3b28271551a578]::panicking::default_hook
   5:     0x7fd0d6d4e279 - std[1c3b28271551a578]::panicking::update_hook::<alloc[93e18355c711b731]::boxed::Box<rustc_driver_impl[b729d44308fea6fe]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fd0d7faa4b2 - std[1c3b28271551a578]::panicking::panic_with_hook
   7:     0x7fd0d7f87852 - std[1c3b28271551a578]::panicking::panic_handler::{closure#0}
   8:     0x7fd0d7f7def9 - std[1c3b28271551a578]::sys::backtrace::__rust_end_short_backtrace::<std[1c3b28271551a578]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fd0d7f895ad - __rustc[98f11d4ffb4a54fb]::rust_begin_unwind
  10:     0x7fd0d481c7dc - core[7deae0c0451d2349]::panicking::panic_fmt
  11:     0x7fd0d69fc447 - <rustc_borrowck[b1a3a3dc4772d542]::borrow_set::GatherBorrows>::gather_reborrows
  12:     0x7fd0d69fc405 - <rustc_borrowck[b1a3a3dc4772d542]::borrow_set::GatherBorrows>::gather_reborrows
  13:     0x7fd0d5070238 - <rustc_borrowck[b1a3a3dc4772d542]::borrow_set::BorrowSet>::build
  14:     0x7fd0d994097d - rustc_borrowck[b1a3a3dc4772d542]::borrowck_collect_region_constraints
  15:     0x7fd0d994f478 - <rustc_borrowck[b1a3a3dc4772d542]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  16:     0x7fd0d8a5b9d5 - rustc_borrowck[b1a3a3dc4772d542]::mir_borrowck
  17:     0x7fd0d8a5b6e3 - rustc_query_impl[a2c45f6ddb9da276]::query_vtables::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7fd0d8a5a10e - rustc_query_impl[a2c45f6ddb9da276]::execution::try_execute_query::<rustc_data_structures[3465cae9aa008a31]::vec_cache::VecCache<rustc_span[2a58d878c64e1a2c]::def_id::LocalDefId, rustc_middle[57c98a37ae0235db]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[57c98a37ae0235db]::dep_graph::graph::DepNodeIndex>, false>
  19:     0x7fd0d8a59c67 - rustc_query_impl[a2c45f6ddb9da276]::query_vtables::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7fd0d8a57d23 - <rustc_middle[57c98a37ae0235db]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[9638b089b1d97f8b]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  21:     0x7fd0d8a57078 - rustc_interface[9638b089b1d97f8b]::passes::analysis
  22:     0x7fd0d9788147 - rustc_query_impl[a2c45f6ddb9da276]::execution::try_execute_query::<rustc_middle[57c98a37ae0235db]::query::caches::SingleCache<rustc_middle[57c98a37ae0235db]::query::erase::ErasedData<[u8; 0usize]>>, false>
  23:     0x7fd0d9787f2b - rustc_query_impl[a2c45f6ddb9da276]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7fd0d983f567 - rustc_interface[9638b089b1d97f8b]::interface::run_compiler::<(), rustc_driver_impl[b729d44308fea6fe]::compiler_entrypoint::{closure#0}>::{closure#2}
  25:     0x7fd0d98c9ec1 - std[1c3b28271551a578]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[9638b089b1d97f8b]::util::run_in_thread_with_globals<rustc_interface[9638b089b1d97f8b]::util::run_in_thread_pool_with_globals<rustc_interface[9638b089b1d97f8b]::interface::run_compiler<(), rustc_driver_impl[b729d44308fea6fe]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:     0x7fd0d98c9c6d - <std[1c3b28271551a578]::thread::lifecycle::spawn_unchecked<rustc_interface[9638b089b1d97f8b]::util::run_in_thread_with_globals<rustc_interface[9638b089b1d97f8b]::util::run_in_thread_pool_with_globals<rustc_interface[9638b089b1d97f8b]::interface::run_compiler<(), rustc_driver_impl[b729d44308fea6fe]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7deae0c0451d2349]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7fd0d98c4c2d - <std[1c3b28271551a578]::sys::thread::unix::Thread>::new::thread_start
  28:     0x7fd0d2898042 - <unknown>
  29:     0x7fd0d292072c - <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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-11-08T18_38_21-894144.txt` to your bug report

note: rustc 1.102.0-nightly (1a4d65fa9 2026-11-08) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `reborrow`
#1 [analysis] running analysis passes on crate `code`
end of query stack

Dominant language
Rust
Stars
121k
Forks
17.3k
Avg merge
2d 21h
Merged PRs (30d)
531

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/rust

All issues in rust-lang/rust

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.