Remove Deref
/DerefMut
impls for RegionConstraintCollector
.
`Deref`/`DerefMut` can be useful, but they can also obfuscate. I don't think they're worth it for `RegionConstraintCollector`. They're also not present on the similar types `OpaqueTypeTable` and `TypeVariableTable`.
This commit is contained in:
parent
e8a0bd6549
commit
8b05df44f9
@ -61,21 +61,6 @@ pub struct RegionConstraintCollector<'a, 'tcx> {
|
|||||||
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
|
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> std::ops::Deref for RegionConstraintCollector<'_, 'tcx> {
|
|
||||||
type Target = RegionConstraintStorage<'tcx>;
|
|
||||||
#[inline]
|
|
||||||
fn deref(&self) -> &RegionConstraintStorage<'tcx> {
|
|
||||||
self.storage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> std::ops::DerefMut for RegionConstraintCollector<'_, 'tcx> {
|
|
||||||
#[inline]
|
|
||||||
fn deref_mut(&mut self) -> &mut RegionConstraintStorage<'tcx> {
|
|
||||||
self.storage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type VarInfos = IndexVec<RegionVid, RegionVariableInfo>;
|
pub type VarInfos = IndexVec<RegionVid, RegionVariableInfo>;
|
||||||
|
|
||||||
/// The full set of region constraints gathered up by the collector.
|
/// The full set of region constraints gathered up by the collector.
|
||||||
@ -324,11 +309,11 @@ pub(crate) fn with_log<'a>(
|
|||||||
|
|
||||||
impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
||||||
pub fn num_region_vars(&self) -> usize {
|
pub fn num_region_vars(&self) -> usize {
|
||||||
self.var_infos.len()
|
self.storage.var_infos.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn region_constraint_data(&self) -> &RegionConstraintData<'tcx> {
|
pub fn region_constraint_data(&self) -> &RegionConstraintData<'tcx> {
|
||||||
&self.data
|
&self.storage.data
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes (and clears) the current set of constraints. Note that
|
/// Takes (and clears) the current set of constraints. Note that
|
||||||
@ -384,17 +369,17 @@ pub fn take_and_reset_data(&mut self) -> RegionConstraintData<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn data(&self) -> &RegionConstraintData<'tcx> {
|
pub fn data(&self) -> &RegionConstraintData<'tcx> {
|
||||||
&self.data
|
&self.storage.data
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn start_snapshot(&mut self) -> RegionSnapshot {
|
pub(super) fn start_snapshot(&mut self) -> RegionSnapshot {
|
||||||
debug!("RegionConstraintCollector: start_snapshot");
|
debug!("RegionConstraintCollector: start_snapshot");
|
||||||
RegionSnapshot { any_unifications: self.any_unifications }
|
RegionSnapshot { any_unifications: self.storage.any_unifications }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn rollback_to(&mut self, snapshot: RegionSnapshot) {
|
pub(super) fn rollback_to(&mut self, snapshot: RegionSnapshot) {
|
||||||
debug!("RegionConstraintCollector: rollback_to({:?})", snapshot);
|
debug!("RegionConstraintCollector: rollback_to({:?})", snapshot);
|
||||||
self.any_unifications = snapshot.any_unifications;
|
self.storage.any_unifications = snapshot.any_unifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn new_region_var(
|
pub(super) fn new_region_var(
|
||||||
@ -402,7 +387,7 @@ pub(super) fn new_region_var(
|
|||||||
universe: ty::UniverseIndex,
|
universe: ty::UniverseIndex,
|
||||||
origin: RegionVariableOrigin,
|
origin: RegionVariableOrigin,
|
||||||
) -> RegionVid {
|
) -> RegionVid {
|
||||||
let vid = self.var_infos.push(RegionVariableInfo { origin, universe });
|
let vid = self.storage.var_infos.push(RegionVariableInfo { origin, universe });
|
||||||
|
|
||||||
let u_vid = self.unification_table_mut().new_key(RegionVariableValue::Unknown { universe });
|
let u_vid = self.unification_table_mut().new_key(RegionVariableValue::Unknown { universe });
|
||||||
assert_eq!(vid, u_vid.vid);
|
assert_eq!(vid, u_vid.vid);
|
||||||
@ -413,7 +398,7 @@ pub(super) fn new_region_var(
|
|||||||
|
|
||||||
/// Returns the origin for the given variable.
|
/// Returns the origin for the given variable.
|
||||||
pub(super) fn var_origin(&self, vid: RegionVid) -> RegionVariableOrigin {
|
pub(super) fn var_origin(&self, vid: RegionVid) -> RegionVariableOrigin {
|
||||||
self.var_infos[vid].origin
|
self.storage.var_infos[vid].origin
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
|
fn add_constraint(&mut self, constraint: Constraint<'tcx>, origin: SubregionOrigin<'tcx>) {
|
||||||
@ -436,8 +421,8 @@ fn add_verify(&mut self, verify: Verify<'tcx>) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let index = self.data.verifys.len();
|
let index = self.storage.data.verifys.len();
|
||||||
self.data.verifys.push(verify);
|
self.storage.data.verifys.push(verify);
|
||||||
self.undo_log.push(AddVerify(index));
|
self.undo_log.push(AddVerify(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,7 +442,7 @@ pub(super) fn make_eqregion(
|
|||||||
(ty::ReVar(a), ty::ReVar(b)) => {
|
(ty::ReVar(a), ty::ReVar(b)) => {
|
||||||
debug!("make_eqregion: unifying {:?} with {:?}", a, b);
|
debug!("make_eqregion: unifying {:?} with {:?}", a, b);
|
||||||
if self.unification_table_mut().unify_var_var(a, b).is_ok() {
|
if self.unification_table_mut().unify_var_var(a, b).is_ok() {
|
||||||
self.any_unifications = true;
|
self.storage.any_unifications = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(ty::ReVar(vid), _) => {
|
(ty::ReVar(vid), _) => {
|
||||||
@ -467,7 +452,7 @@ pub(super) fn make_eqregion(
|
|||||||
.unify_var_value(vid, RegionVariableValue::Known { value: b })
|
.unify_var_value(vid, RegionVariableValue::Known { value: b })
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
self.any_unifications = true;
|
self.storage.any_unifications = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
(_, ty::ReVar(vid)) => {
|
(_, ty::ReVar(vid)) => {
|
||||||
@ -477,7 +462,7 @@ pub(super) fn make_eqregion(
|
|||||||
.unify_var_value(vid, RegionVariableValue::Known { value: a })
|
.unify_var_value(vid, RegionVariableValue::Known { value: a })
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
self.any_unifications = true;
|
self.storage.any_unifications = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
(_, _) => {}
|
(_, _) => {}
|
||||||
@ -499,7 +484,7 @@ pub(super) fn member_constraint(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.data.member_constraints.push(MemberConstraint {
|
self.storage.data.member_constraints.push(MemberConstraint {
|
||||||
key,
|
key,
|
||||||
definition_span,
|
definition_span,
|
||||||
hidden_ty,
|
hidden_ty,
|
||||||
@ -615,8 +600,8 @@ pub fn probe_value(
|
|||||||
|
|
||||||
fn combine_map(&mut self, t: CombineMapType) -> &mut CombineMap<'tcx> {
|
fn combine_map(&mut self, t: CombineMapType) -> &mut CombineMap<'tcx> {
|
||||||
match t {
|
match t {
|
||||||
Glb => &mut self.glbs,
|
Glb => &mut self.storage.glbs,
|
||||||
Lub => &mut self.lubs,
|
Lub => &mut self.storage.lubs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,11 +654,12 @@ pub fn vars_since_snapshot(
|
|||||||
&self,
|
&self,
|
||||||
value_count: usize,
|
value_count: usize,
|
||||||
) -> (Range<RegionVid>, Vec<RegionVariableOrigin>) {
|
) -> (Range<RegionVid>, Vec<RegionVariableOrigin>) {
|
||||||
let range = RegionVid::from(value_count)..RegionVid::from(self.unification_table.len());
|
let range =
|
||||||
|
RegionVid::from(value_count)..RegionVid::from(self.storage.unification_table.len());
|
||||||
(
|
(
|
||||||
range.clone(),
|
range.clone(),
|
||||||
(range.start.index()..range.end.index())
|
(range.start.index()..range.end.index())
|
||||||
.map(|index| self.var_infos[ty::RegionVid::from(index)].origin)
|
.map(|index| self.storage.var_infos[ty::RegionVid::from(index)].origin)
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user