[ICE]: `expected region 'static to be of kind ReVar`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
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
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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/rust
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-libs
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
Difficulty 1/5 Under an hour Newbie friendliness 72/100
rust-lang/rust#165504 · 1 comment ·
Maintainers usually reply within 1 day
-
relnotes relnotes-tracking-issue T-libs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
unclear wording in vec macroPossibly taken @Suhird claimed this 5 days ago. OpenA-docs A-slice-vec T-libs
Difficulty 1/5 1-3 hours Newbie friendliness 70/100
rust-lang/rust#165360 · 6 comments · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
bytecodealliance/rustix#1736 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
longbridge/gpui-kit#3871 ·
Maintainers usually reply within 1 day
-
area:models enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 84/100
servo/rust-smallvec#864 ·