[ICE]: `Tracking borrow behind shared reference.`

未关闭
#165,604 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust
领域
compilers

调研方向

Start with the reproducer in the issue body and the referenced code in compiler/rustc_borrowck/src/places_conflict.rs around lines 226–238. Reproduce the ICE with the provided nightly compiler command, then trace the borrow-checking path that reaches the panic. Done means the reproducer produces a compiler diagnostic or compiles without an internal compiler error.

由索引模型根据 Issue 内容生成。

描述

C-bug F-reborrow I-ICE needs-triage T-compiler

snippet:

#![feature(reborrow)]
use std::marker::{PhantomData, Reborrow};
#[derive(Reborrow)]
struct CustomMarker<'a>(PhantomData<&'a ()>);
fn method<'a>(_a: CustomMarker) -> &'a () {
    todo!()
}
fn main() {
    let mut a = CustomMarker(PhantomData);
    let b = &a;
    let _ = method(*b);
}

Version information

rustc 1.102.0-nightly (e30d778f3 2026-11-07)
binary: rustc
commit-hash: e30d778f3029b78bb9c2e0dbe11a3b7389b652c4
commit-date: 2026-11-07
host: x86_64-unknown-linux-gnu
release: 1.102.0-nightly
LLVM version: 23.1.5

Possibly related line of code:
https://github.com/rust-lang/rust/blob/e30d778f3029b78bb9c2e0dbe11a3b7389b652c4/compiler/rustc_borrowck/src/places_conflict.rs#L226-L238

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

`--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

error: internal compiler error: /rustc-dev/e30d778f3029b78bb9c2e0dbe11a3b7389b652c4/compiler/rustc_borrowck/src/places_conflict.rs:232:21: Tracking borrow behind shared reference.


thread 'rustc' (2614827) panicked at /rustc-dev/e30d778f3029b78bb9c2e0dbe11a3b7389b652c4/compiler/rustc_borrowck/src/places_conflict.rs:232:21:
Box<dyn Any>
stack backtrace:
   0:     0x7fafb1bb1b46 - <<std[78fff3269c571d64]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[ab05fe898412e670]::fmt::Display>::fmt
   1:     0x7fafb2210d0f - core[ab05fe898412e670]::fmt::write
   2:     0x7fafb1bc66fc - <std[78fff3269c571d64]::sys::stdio::unix::Stderr as core[ab05fe898412e670]::io::write::Write>::write_fmt
   3:     0x7fafb1b82c5a - std[78fff3269c571d64]::panicking::default_hook::{closure#0}
   4:     0x7fafb1ba54a3 - std[78fff3269c571d64]::panicking::default_hook
   5:     0x7fafb094bf19 - std[78fff3269c571d64]::panicking::update_hook::<alloc[cce08dc9b884395a]::boxed::Box<rustc_driver_impl[81060cdeec855cdc]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fafb1ba5942 - std[78fff3269c571d64]::panicking::panic_with_hook
   7:     0x7fafb17423cd - std[78fff3269c571d64]::panicking::begin_panic::<rustc_span[a3f41dffa4d3a048]::macros::ExplicitBug>::{closure#0}
   8:     0x7fafb1740426 - std[78fff3269c571d64]::sys::backtrace::__rust_end_short_backtrace::<std[78fff3269c571d64]::panicking::begin_panic<rustc_span[a3f41dffa4d3a048]::macros::ExplicitBug>::{closure#0}, !>
   9:     0x7fafb173facb - std[78fff3269c571d64]::panicking::begin_panic::<rustc_span[a3f41dffa4d3a048]::macros::ExplicitBug>
  10:     0x7fafae0d4aa1 - rustc_span[a3f41dffa4d3a048]::macros::bug_impl
  11:     0x7fafb22ba87a - rustc_borrowck[844e9863c7f9bfb9]::get_flow_results
  12:     0x7fafb3545fe2 - rustc_borrowck[844e9863c7f9bfb9]::borrowck_check_region_constraints
  13:     0x7fafb353f19e - <rustc_borrowck[844e9863c7f9bfb9]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  14:     0x7fafb25ee015 - rustc_borrowck[844e9863c7f9bfb9]::mir_borrowck
  15:     0x7fafb25edd27 - rustc_query_impl[34f6a597f1724d62]::query_vtables::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  16:     0x7fafb25ec74e - rustc_query_impl[34f6a597f1724d62]::execution::try_execute_query::<rustc_data_structures[930b7a29102cf109]::vec_cache::VecCache<rustc_span[a3f41dffa4d3a048]::def_id::LocalDefId, rustc_middle[a84b5397e30ac3fc]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[a84b5397e30ac3fc]::dep_graph::graph::DepNodeIndex>, false>
  17:     0x7fafb25ec2a7 - rustc_query_impl[34f6a597f1724d62]::query_vtables::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
  18:     0x7fafb25ea363 - <rustc_middle[a84b5397e30ac3fc]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[23b467da62203591]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  19:     0x7fafb25e96b8 - rustc_interface[23b467da62203591]::passes::analysis
  20:     0x7fafb3360287 - rustc_query_impl[34f6a597f1724d62]::execution::try_execute_query::<rustc_middle[a84b5397e30ac3fc]::query::caches::SingleCache<rustc_middle[a84b5397e30ac3fc]::query::erase::ErasedData<[u8; 0usize]>>, false>
  21:     0x7fafb336006b - rustc_query_impl[34f6a597f1724d62]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  22:     0x7fafb342ef58 - rustc_interface[23b467da62203591]::interface::run_compiler::<(), rustc_driver_impl[81060cdeec855cdc]::compiler_entrypoint::{closure#0}>::{closure#2}
  23:     0x7fafb34e4b01 - std[78fff3269c571d64]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[23b467da62203591]::util::run_in_thread_with_globals<rustc_interface[23b467da62203591]::util::run_in_thread_pool_with_globals<rustc_interface[23b467da62203591]::interface::run_compiler<(), rustc_driver_impl[81060cdeec855cdc]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  24:     0x7fafb34e48ad - <std[78fff3269c571d64]::thread::lifecycle::spawn_unchecked<rustc_interface[23b467da62203591]::util::run_in_thread_with_globals<rustc_interface[23b467da62203591]::util::run_in_thread_pool_with_globals<rustc_interface[23b467da62203591]::interface::run_compiler<(), rustc_driver_impl[81060cdeec855cdc]::compiler_entrypoint::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[ab05fe898412e670]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7fafb34e84ad - <std[78fff3269c571d64]::sys::thread::unix::Thread>::new::thread_start
  26:     0x7fafac498042 - <unknown>
  27:     0x7fafac52072c - <unknown>
  28:                0x0 - <unknown>

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.102.0-nightly (e30d778f3 2026-11-07) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error


@rustbot label +F-reborrow

主要语言
Rust
星标
121k
派生
17.3k
平均合并
2 天 21 小时
30 天内合并 PR
531

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rust-lang/rust 的其他 Issue

查看 rust-lang/rust 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。