1
Fork 0

rm RegionInferenceContext::var_infos

we already track this info in the `definitions` field
This commit is contained in:
lcnr 2025-04-07 12:18:56 +02:00
parent b9856b6e40
commit 1862b311f6
4 changed files with 8 additions and 14 deletions

View file

@ -406,8 +406,8 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
// started MIR borrowchecking with, so the region // started MIR borrowchecking with, so the region
// constraints have already been taken. Use the data from // constraints have already been taken. Use the data from
// our `mbcx` instead. // our `mbcx` instead.
|vid| mbcx.regioncx.var_infos[vid].origin, |vid| RegionVariableOrigin::Nll(mbcx.regioncx.definitions[vid].origin),
|vid| mbcx.regioncx.var_infos[vid].universe, |vid| mbcx.regioncx.definitions[vid].universe,
) )
} }
} }

View file

@ -8,9 +8,7 @@ use rustc_errors::{Applicability, Diag, EmissionGuarantee, MultiSpan, listify};
use rustc_hir::def::{CtorKind, Namespace}; use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::{self as hir, CoroutineKind, LangItem}; use rustc_hir::{self as hir, CoroutineKind, LangItem};
use rustc_index::IndexSlice; use rustc_index::IndexSlice;
use rustc_infer::infer::{ use rustc_infer::infer::{BoundRegionConversionTime, NllRegionVariableOrigin};
BoundRegionConversionTime, NllRegionVariableOrigin, RegionVariableOrigin,
};
use rustc_infer::traits::SelectionError; use rustc_infer::traits::SelectionError;
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::mir::{ use rustc_middle::mir::{
@ -633,9 +631,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
) { ) {
let predicate_span = path.iter().find_map(|constraint| { let predicate_span = path.iter().find_map(|constraint| {
let outlived = constraint.sub; let outlived = constraint.sub;
if let Some(origin) = self.regioncx.var_infos.get(outlived) if let Some(origin) = self.regioncx.definitions.get(outlived)
&& let RegionVariableOrigin::Nll(NllRegionVariableOrigin::Placeholder(_)) = && let NllRegionVariableOrigin::Placeholder(_) = origin.origin
origin.origin
&& let ConstraintCategory::Predicate(span) = constraint.category && let ConstraintCategory::Predicate(span) = constraint.category
{ {
Some(span) Some(span)

View file

@ -334,7 +334,7 @@ fn emit_mermaid_nll_regions<'tcx>(
writeln!(out, "flowchart TD")?; writeln!(out, "flowchart TD")?;
// Emit the region nodes. // Emit the region nodes.
for region in regioncx.var_infos.indices() { for region in regioncx.definitions.indices() {
write!(out, "{}[\"", region.as_usize())?; write!(out, "{}[\"", region.as_usize())?;
render_region(region, regioncx, out)?; render_region(region, regioncx, out)?;
writeln!(out, "\"]")?; writeln!(out, "\"]")?;
@ -387,7 +387,7 @@ fn emit_mermaid_nll_sccs<'tcx>(
// Gather and emit the SCC nodes. // Gather and emit the SCC nodes.
let mut nodes_per_scc: IndexVec<_, _> = let mut nodes_per_scc: IndexVec<_, _> =
regioncx.constraint_sccs().all_sccs().map(|_| Vec::new()).collect(); regioncx.constraint_sccs().all_sccs().map(|_| Vec::new()).collect();
for region in regioncx.var_infos.indices() { for region in regioncx.definitions.indices() {
let scc = regioncx.constraint_sccs().scc(region); let scc = regioncx.constraint_sccs().scc(region);
nodes_per_scc[scc].push(region); nodes_per_scc[scc].push(region);
} }

View file

@ -139,13 +139,11 @@ impl RegionTracker {
} }
pub struct RegionInferenceContext<'tcx> { pub struct RegionInferenceContext<'tcx> {
pub var_infos: VarInfos,
/// Contains the definition for every region variable. Region /// Contains the definition for every region variable. Region
/// variables are identified by their index (`RegionVid`). The /// variables are identified by their index (`RegionVid`). The
/// definition contains information about where the region came /// definition contains information about where the region came
/// from as well as its final inferred value. /// from as well as its final inferred value.
definitions: IndexVec<RegionVid, RegionDefinition<'tcx>>, pub(crate) definitions: IndexVec<RegionVid, RegionDefinition<'tcx>>,
/// The liveness constraints added to each region. For most /// The liveness constraints added to each region. For most
/// regions, these start out empty and steadily grow, though for /// regions, these start out empty and steadily grow, though for
@ -449,7 +447,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
Rc::new(member_constraints.into_mapped(|r| constraint_sccs.scc(r))); Rc::new(member_constraints.into_mapped(|r| constraint_sccs.scc(r)));
let mut result = Self { let mut result = Self {
var_infos,
definitions, definitions,
liveness_constraints, liveness_constraints,
constraints, constraints,