{"record":{"id":"4b5ab30c8b01e91d","repo":"rust-lang/rust","slug":"accessing-live-loans-requires-zpolonius-next","errorCode":null,"errorMessage":"Accessing live loans requires `-Zpolonius=next`","messagePattern":"Accessing live loans requires `-Zpolonius=next`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_borrowck/src/region_infer/values.rs","lineNumber":213,"sourceCode":"        self.location_map.point_from_location(location)\n    }\n\n    #[inline]\n    pub(crate) fn location_from_point(&self, point: PointIndex) -> Location {\n        self.location_map.to_location(point)\n    }\n\n    /// When using `-Zpolonius=next`, records the given live loans for the loan scopes and active\n    /// loans dataflow computations.\n    pub(crate) fn record_live_loans(&mut self, live_loans: LiveLoans) {\n        self.live_loans = Some(live_loans);\n    }\n\n    /// When using `-Zpolonius=next`, returns whether the `loan_idx` is live at the given `point`.\n    pub(crate) fn is_loan_live_at(&self, loan_idx: BorrowIndex, point: PointIndex) -> bool {\n        self.live_loans\n            .as_ref()\n            .expect(\"Accessing live loans requires `-Zpolonius=next`\")\n            .contains(point, loan_idx)\n    }\n}\n\n/// Maps from `ty::PlaceholderRegion` values that are used in the rest of\n/// rustc to the internal `PlaceholderIndex` values that are used in\n/// NLL.\n#[derive(Debug, Default)]\n#[derive(Clone)] // FIXME(#146079)\npub(crate) struct PlaceholderIndices<'tcx> {\n    indices: FxIndexSet<ty::PlaceholderRegion<'tcx>>,\n}\n\nimpl<'tcx> PlaceholderIndices<'tcx> {\n    /// Returns the `PlaceholderIndex` for the inserted `PlaceholderRegion`\n    pub(crate) fn insert(&mut self, placeholder: ty::PlaceholderRegion<'tcx>) -> PlaceholderIndex {\n        let (index, _) = self.indices.insert_full(placeholder);\n        index.into()","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_borrowck/src/region_infer/values.rs#L195-L231","documentation":"This assertion fires in `LivenessValues::is_loan_live_at`, which checks whether a specific borrow (loan) is live at a given program point. The `live_loans` field is an `Option` that is only populated via `record_live_loans` when `-Zpolonius=next` is active. If any code path calls `is_loan_live_at` without `-Zpolonius=next` having recorded live loans, the `.expect(...)` panics.","triggerScenarios":"Calling `is_loan_live_at` (directly or via a code path that reaches it) when the borrow checker ran without `-Zpolonius=next`. This typically means a diagnostic or analysis routine that uses polonius-specific loan-liveness data was invoked in a non-polonius compilation, or a polonius=next body had its `record_live_loans` call skipped.","commonSituations":"Nightly Rust with code that triggers a diagnostic path (e.g., a borrow-check error diagnostic) that queries live-loan status, but the compilation wasn't started with `-Zpolonius=next`. Can also happen when tooling (rustdoc, clippy, or a proc-macro) invokes the borrow checker in a mode that doesn't set up polonius data.","solutions":["Add `-Zpolonius=next` to RUSTFLAGS if you need live-loan data: `RUSTFLAGS='-Zpolonius=next' cargo build`.","Remove any code or tooling that relies on `is_loan_live_at` outside of polonius=next mode.","File a bug — the compiler should guard `is_loan_live_at` callers with a flag check rather than panicking.","Update nightly; the polonius=next guard wiring changes frequently."],"exampleFix":"# before (is_loan_live_at called without polonius=next)\nRUSTFLAGS='' cargo build\n\n# after (enable polonius=next for live-loan support)\nRUSTFLAGS='-Zpolonius=next' cargo build","handlingStrategy":"validation","validationCode":"// In a custom rustc driver, check before accessing live loans:\nif tcx.sess.opts.unstable_opts.polonius.is_next_enabled() {\n    let is_live = regioncx.liveness_constraints().is_loan_live_at(loan, point);\n} else {\n    // polonius=next not enabled; cannot check live loans\n    return false;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call is_loan_live_at when -Zpolonius=next is active.","Guard all polonius-specific API calls with flag checks.","Don't share diagnostic code between NLL and polonius modes without conditional gates.","Document which functions require -Zpolonius=next in compiler-internal docs."],"tags":["rustc","borrowck","polonius","ice","nightly","compiler-internal"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}