Remove a couple of Rc's from RegionInferenceContext
This commit is contained in:
parent
54b7d21f59
commit
4b46271841
2 changed files with 28 additions and 9 deletions
|
@ -73,6 +73,24 @@ crate use place_ext::PlaceExt;
|
||||||
crate use places_conflict::{places_conflict, PlaceConflictBias};
|
crate use places_conflict::{places_conflict, PlaceConflictBias};
|
||||||
crate use region_infer::RegionInferenceContext;
|
crate use region_infer::RegionInferenceContext;
|
||||||
|
|
||||||
|
/// An owned immutable value.
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Frozen<T>(T);
|
||||||
|
|
||||||
|
impl<T> Frozen<T> {
|
||||||
|
pub fn freeze(val: T) -> Self {
|
||||||
|
Frozen(val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> std::ops::Deref for Frozen<T> {
|
||||||
|
type Target = T;
|
||||||
|
|
||||||
|
fn deref(&self) -> &T {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME(eddyb) perhaps move this somewhere more centrally.
|
// FIXME(eddyb) perhaps move this somewhere more centrally.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
crate struct Upvar {
|
crate struct Upvar {
|
||||||
|
@ -1577,11 +1595,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
mpi,
|
mpi,
|
||||||
);
|
);
|
||||||
} // Only query longest prefix with a MovePath, not further
|
} // Only query longest prefix with a MovePath, not further
|
||||||
// ancestors; dataflow recurs on children when parents
|
// ancestors; dataflow recurs on children when parents
|
||||||
// move (to support partial (re)inits).
|
// move (to support partial (re)inits).
|
||||||
//
|
//
|
||||||
// (I.e., querying parents breaks scenario 7; but may want
|
// (I.e., querying parents breaks scenario 7; but may want
|
||||||
// to do such a query based on partial-init feature-gate.)
|
// to do such a query based on partial-init feature-gate.)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subslices correspond to multiple move paths, so we iterate through the
|
/// Subslices correspond to multiple move paths, so we iterate through the
|
||||||
|
|
|
@ -31,6 +31,7 @@ use crate::borrow_check::{
|
||||||
},
|
},
|
||||||
type_check::{free_region_relations::UniversalRegionRelations, Locations},
|
type_check::{free_region_relations::UniversalRegionRelations, Locations},
|
||||||
universal_regions::UniversalRegions,
|
universal_regions::UniversalRegions,
|
||||||
|
Frozen,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod dump_mir;
|
mod dump_mir;
|
||||||
|
@ -54,12 +55,12 @@ pub struct RegionInferenceContext<'tcx> {
|
||||||
liveness_constraints: LivenessValues<RegionVid>,
|
liveness_constraints: LivenessValues<RegionVid>,
|
||||||
|
|
||||||
/// The outlives constraints computed by the type-check.
|
/// The outlives constraints computed by the type-check.
|
||||||
constraints: Rc<OutlivesConstraintSet>,
|
constraints: Frozen<OutlivesConstraintSet>,
|
||||||
|
|
||||||
/// The constraint-set, but in graph form, making it easy to traverse
|
/// The constraint-set, but in graph form, making it easy to traverse
|
||||||
/// the constraints adjacent to a particular region. Used to construct
|
/// the constraints adjacent to a particular region. Used to construct
|
||||||
/// the SCC (see `constraint_sccs`) and for error reporting.
|
/// the SCC (see `constraint_sccs`) and for error reporting.
|
||||||
constraint_graph: Rc<NormalConstraintGraph>,
|
constraint_graph: Frozen<NormalConstraintGraph>,
|
||||||
|
|
||||||
/// The SCC computed from `constraints` and the constraint
|
/// The SCC computed from `constraints` and the constraint
|
||||||
/// graph. We have an edge from SCC A to SCC B if `A: B`. Used to
|
/// graph. We have an edge from SCC A to SCC B if `A: B`. Used to
|
||||||
|
@ -263,8 +264,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
.map(|info| RegionDefinition::new(info.universe, info.origin))
|
.map(|info| RegionDefinition::new(info.universe, info.origin))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let constraints = Rc::new(outlives_constraints); // freeze constraints
|
let constraints = Frozen::freeze(outlives_constraints);
|
||||||
let constraint_graph = Rc::new(constraints.graph(definitions.len()));
|
let constraint_graph = Frozen::freeze(constraints.graph(definitions.len()));
|
||||||
let fr_static = universal_regions.fr_static;
|
let fr_static = universal_regions.fr_static;
|
||||||
let constraint_sccs = Rc::new(constraints.compute_sccs(&constraint_graph, fr_static));
|
let constraint_sccs = Rc::new(constraints.compute_sccs(&constraint_graph, fr_static));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue