Skip to content

ICE: polonius: None in region infer with unconditional panic #135646

Open
@matthiaskrgr

Description

@matthiaskrgr

not sure why this only panics in edition 2024 🤔

auto-reduced (treereduce-rust):

//@compile-flags: --edition=2024 -Zpolonius=next
fn main() {
    &{ [1, 2, 3][4] };
}

original:

//@ build-pass
//@ ignore-pass (test emits codegen-time warnings and verifies that they are not errors)

#![warn(unconditional_panic)]

fn main() {
    &{ [1, 2, 3][4] };
    //~^ WARN operation will panic
}

Version information

rustc 1.86.0-nightly (bcd0683e5 2025-01-17)
binary: rustc
commit-hash: bcd0683e5dce1945b5d940714742e7502883bb5c
commit-date: 2025-01-17
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Possibly related line of code:

// larger than that.
self.find_constraint_paths_between_regions(fr1, |r| {
self.cannot_name_placeholder(r, fr1)
})
})
.map(|(_path, r)| r)
.unwrap()
}
/// Get the region outlived by `longer_fr` and live at `element`.
pub(crate) fn region_from_element(
&self,
longer_fr: RegionVid,

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

Program output


thread 'rustc' panicked at compiler/rustc_borrowck/src/region_infer/mod.rs:1888:10:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7077524fb0ca - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h245d3d13c9e117ef
   1:     0x707752c12d26 - core::fmt::write::ha5c79450f6a60aba
   2:     0x707753b95891 - std::io::Write::write_fmt::hc0bb623be5e87022
   3:     0x7077524faf22 - std::sys::backtrace::BacktraceLock::print::h5f0375c539e6bbfe
   4:     0x7077524fd3a2 - std::panicking::default_hook::{{closure}}::hfaae0dc7005f1f46
   5:     0x7077524fd22a - std::panicking::default_hook::had3887552141764d
   6:     0x70775165e33b - std[970739192a5a8910]::panicking::update_hook::<alloc[c190f769f0908da9]::boxed::Box<rustc_driver_impl[98a1c83b91f31d14]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7077524fdee3 - std::panicking::rust_panic_with_hook::h0f6e30840497503a
   8:     0x7077524fdba6 - std::panicking::begin_panic_handler::{{closure}}::h00d1f33c4abe282b
   9:     0x7077524fb5a9 - std::sys::backtrace::__rust_end_short_backtrace::h7f80f131d37aefa4
  10:     0x7077524fd89d - rust_begin_unwind
  11:     0x70774f1a8530 - core::panicking::panic_fmt::h313dbd2ed26f8657
  12:     0x70774fcc082c - core::panicking::panic::h6bed83e7eae20130
  13:     0x70775067d5a9 - core::option::unwrap_failed::h5e1ae1d3b98bd9cb
  14:     0x70775143be47 - <rustc_borrowck[4bd42f5d1352065e]::region_infer::RegionInferenceContext>::find_sub_region_live_at
  15:     0x707750fd0fb4 - <rustc_borrowck[4bd42f5d1352065e]::MirBorrowckCtxt>::explain_why_borrow_contains_point
  16:     0x707750e18b6b - <rustc_borrowck[4bd42f5d1352065e]::MirBorrowckCtxt>::report_borrowed_value_does_not_live_long_enough
  17:     0x707753cf134f - rustc_borrowck[4bd42f5d1352065e]::do_mir_borrowck
  18:     0x707753cc352f - rustc_query_impl[a1940b4b03f25947]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a1940b4b03f25947]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a423a87a2792eea]::query::erase::Erased<[u8; 8usize]>>
  19:     0x707752f2260e - rustc_query_system[f87afe778d5ed02f]::query::plumbing::try_execute_query::<rustc_query_impl[a1940b4b03f25947]::DynamicConfig<rustc_data_structures[7c7a3305c98b4df4]::vec_cache::VecCache<rustc_span[e90766ed4fb19497]::def_id::LocalDefId, rustc_middle[1a423a87a2792eea]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[f87afe778d5ed02f]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[a1940b4b03f25947]::plumbing::QueryCtxt, false>
  20:     0x707752f22113 - rustc_query_impl[a1940b4b03f25947]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  21:     0x707752f16fb0 - rustc_interface[f2cc204a1e18dc42]::passes::run_required_analyses
  22:     0x707753b9109e - rustc_interface[f2cc204a1e18dc42]::passes::analysis
  23:     0x707753b9106f - rustc_query_impl[a1940b4b03f25947]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[a1940b4b03f25947]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[1a423a87a2792eea]::query::erase::Erased<[u8; 0usize]>>
  24:     0x707753be8355 - rustc_query_system[f87afe778d5ed02f]::query::plumbing::try_execute_query::<rustc_query_impl[a1940b4b03f25947]::DynamicConfig<rustc_query_system[f87afe778d5ed02f]::query::caches::SingleCache<rustc_middle[1a423a87a2792eea]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[a1940b4b03f25947]::plumbing::QueryCtxt, false>
  25:     0x707753be808e - rustc_query_impl[a1940b4b03f25947]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  26:     0x707753c5c2e9 - rustc_interface[f2cc204a1e18dc42]::passes::create_and_enter_global_ctxt::<core[31d5326fba56f7df]::option::Option<rustc_interface[f2cc204a1e18dc42]::queries::Linker>, rustc_driver_impl[98a1c83b91f31d14]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  27:     0x707753c4f4d6 - rustc_interface[f2cc204a1e18dc42]::interface::run_compiler::<(), rustc_driver_impl[98a1c83b91f31d14]::run_compiler::{closure#0}>::{closure#1}
  28:     0x707753a92c07 - std[970739192a5a8910]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f2cc204a1e18dc42]::util::run_in_thread_with_globals<rustc_interface[f2cc204a1e18dc42]::util::run_in_thread_pool_with_globals<rustc_interface[f2cc204a1e18dc42]::interface::run_compiler<(), rustc_driver_impl[98a1c83b91f31d14]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  29:     0x707753a928d9 - <<std[970739192a5a8910]::thread::Builder>::spawn_unchecked_<rustc_interface[f2cc204a1e18dc42]::util::run_in_thread_with_globals<rustc_interface[f2cc204a1e18dc42]::util::run_in_thread_pool_with_globals<rustc_interface[f2cc204a1e18dc42]::interface::run_compiler<(), rustc_driver_impl[98a1c83b91f31d14]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[31d5326fba56f7df]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  30:     0x707753a9206b - std::sys::pal::unix::thread::Thread::new::thread_start::h84cef28dceb72f89
  31:     0x70774dea339d - <unknown>
  32:     0x70774df2849c - <unknown>
  33:                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.86.0-nightly (bcd0683e5 2025-01-17) running on x86_64-unknown-linux-gnu

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

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️NLL-poloniusIssues related for using Polonius in the borrow checkerS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions