[−][src]Struct rustc_infer::infer::region_constraints::RegionConstraintCollector
Fields
storage: &'a mut RegionConstraintStorage<'tcx>undo_log: &'a mut InferCtxtUndoLogs<'tcx>Implementations
impl<'tcx, '_> RegionConstraintCollector<'_, 'tcx>[src]
pub fn leak_check(
&mut self,
tcx: TyCtxt<'tcx>,
overly_polymorphic: bool,
max_universe: UniverseIndex,
snapshot: &CombinedSnapshot<'_, 'tcx>
) -> RelateResult<'tcx, ()>[src]
&mut self,
tcx: TyCtxt<'tcx>,
overly_polymorphic: bool,
max_universe: UniverseIndex,
snapshot: &CombinedSnapshot<'_, 'tcx>
) -> RelateResult<'tcx, ()>
Searches new universes created during snapshot, looking for
placeholders that may "leak" out from the universes they are contained
in. If any leaking placeholders are found, then an Err is returned
(typically leading to the snapshot being reversed).
The leak check used to be the only way we had to handle higher-ranked obligations. Now that we have integrated universes into the region solvers, this is no longer the case, but we retain the leak check for backwards compatibility purposes. In particular, it lets us make "early" decisions about whether a region error will be reported that are used in coherence and elsewhere -- see #56105 and #59490 for more details. The eventual fate of the leak checker is not yet settled.
The leak checker works by searching for the following error patterns:
- P1: P2, where P1 != P2
- P1: R, where R is in some universe that cannot name P1
The idea here is that each of these patterns represents something that
the region solver would eventually report as an error, so we can detect
the error early. There is a fly in the ointment, though, in that this is
not entirely true. In particular, in the future, we may extend the
environment with implied bounds or other info about how placeholders
relate to regions in outer universes. In that case, P1: R for example
might become solveable.
Summary of the implementation
The leak checks as follows. First, we construct a graph where R2: R1
implies R2 -> R1, and we compute the SCCs.
For each SCC S, we compute:
- what placeholder P it must be equal to, if any
- if there are multiple placeholders that must be equal, report an error because
P1: P2
- if there are multiple placeholders that must be equal, report an error because
- the minimum universe of its constituents
Then we walk the SCCs in dependency order and compute
- what placeholder they must outlive transitively
- if they must also be equal to a placeholder, report an error because
P1: P2
- if they must also be equal to a placeholder, report an error because
- minimum universe U of all SCCs they must outlive
- if they must also be equal to a placeholder P, and U cannot name P, report an error, as that
indicates
P: RandRis in an incompatible universe
- if they must also be equal to a placeholder P, and U cannot name P, report an error, as that
indicates
Historical note
Older variants of the leak check used to report errors for these patterns, but we no longer do:
- R: P1, even if R cannot name P1, because R = 'static is a valid sol'n
- R: P1, R: P2, as above
impl<'tcx, '_> RegionConstraintCollector<'_, 'tcx>[src]
pub fn num_region_vars(&self) -> usize[src]
pub fn region_constraint_data(&self) -> &RegionConstraintData<'tcx>[src]
pub fn into_infos_and_data(self) -> (VarInfos, RegionConstraintData<'tcx>)[src]
Once all the constraints have been gathered, extract out the final data.
Not legal during a snapshot.
pub fn take_and_reset_data(&mut self) -> RegionConstraintData<'tcx>[src]
Takes (and clears) the current set of constraints. Note that the set of variables remains intact, but all relationships between them are reset. This is used during NLL checking to grab the set of constraints that arose from a particular operation.
We don't want to leak relationships between variables between
points because just because (say) r1 == r2 was true at some
point P in the graph doesn't imply that it will be true at
some other point Q, in NLL.
Not legal during a snapshot.
pub fn data(&self) -> &RegionConstraintData<'tcx>[src]
pub fn start_snapshot(&mut self) -> RegionSnapshot[src]
pub fn rollback_to(&mut self, snapshot: RegionSnapshot)[src]
pub fn new_region_var(
&mut self,
universe: UniverseIndex,
origin: RegionVariableOrigin
) -> RegionVid[src]
&mut self,
universe: UniverseIndex,
origin: RegionVariableOrigin
) -> RegionVid
pub fn var_universe(&self, vid: RegionVid) -> UniverseIndex[src]
Returns the universe for the given variable.
pub fn var_origin(&self, vid: RegionVid) -> RegionVariableOrigin[src]
Returns the origin for the given variable.
pub(in infer::region_constraints) fn add_constraint(
&mut self,
constraint: Constraint<'tcx>,
origin: SubregionOrigin<'tcx>
)[src]
&mut self,
constraint: Constraint<'tcx>,
origin: SubregionOrigin<'tcx>
)
pub(in infer::region_constraints) fn add_verify(
&mut self,
verify: Verify<'tcx>
)[src]
&mut self,
verify: Verify<'tcx>
)
pub fn add_given(&mut self, sub: Region<'tcx>, sup: RegionVid)[src]
pub fn make_eqregion(
&mut self,
origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>,
sup: Region<'tcx>
)[src]
&mut self,
origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>,
sup: Region<'tcx>
)
pub fn member_constraint(
&mut self,
opaque_type_def_id: DefId,
definition_span: Span,
hidden_ty: Ty<'tcx>,
member_region: Region<'tcx>,
choice_regions: &Lrc<Vec<Region<'tcx>>>
)[src]
&mut self,
opaque_type_def_id: DefId,
definition_span: Span,
hidden_ty: Ty<'tcx>,
member_region: Region<'tcx>,
choice_regions: &Lrc<Vec<Region<'tcx>>>
)
pub fn make_subregion(
&mut self,
origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>,
sup: Region<'tcx>
)[src]
&mut self,
origin: SubregionOrigin<'tcx>,
sub: Region<'tcx>,
sup: Region<'tcx>
)
pub fn verify_generic_bound(
&mut self,
origin: SubregionOrigin<'tcx>,
kind: GenericKind<'tcx>,
sub: Region<'tcx>,
bound: VerifyBound<'tcx>
)[src]
&mut self,
origin: SubregionOrigin<'tcx>,
kind: GenericKind<'tcx>,
sub: Region<'tcx>,
bound: VerifyBound<'tcx>
)
pub fn lub_regions(
&mut self,
tcx: TyCtxt<'tcx>,
origin: SubregionOrigin<'tcx>,
a: Region<'tcx>,
b: Region<'tcx>
) -> Region<'tcx>[src]
&mut self,
tcx: TyCtxt<'tcx>,
origin: SubregionOrigin<'tcx>,
a: Region<'tcx>,
b: Region<'tcx>
) -> Region<'tcx>
pub fn glb_regions(
&mut self,
tcx: TyCtxt<'tcx>,
origin: SubregionOrigin<'tcx>,
a: Region<'tcx>,
b: Region<'tcx>
) -> Region<'tcx>[src]
&mut self,
tcx: TyCtxt<'tcx>,
origin: SubregionOrigin<'tcx>,
a: Region<'tcx>,
b: Region<'tcx>
) -> Region<'tcx>
pub fn opportunistic_resolve_var(&mut self, rid: RegionVid) -> RegionVid[src]
pub(in infer::region_constraints) fn combine_map(
&mut self,
t: CombineMapType
) -> &mut FxHashMap<TwoRegions<'tcx>, RegionVid>[src]
&mut self,
t: CombineMapType
) -> &mut FxHashMap<TwoRegions<'tcx>, RegionVid>
pub(in infer::region_constraints) fn combine_vars(
&mut self,
tcx: TyCtxt<'tcx>,
t: CombineMapType,
a: Region<'tcx>,
b: Region<'tcx>,
origin: SubregionOrigin<'tcx>
) -> Region<'tcx>[src]
&mut self,
tcx: TyCtxt<'tcx>,
t: CombineMapType,
a: Region<'tcx>,
b: Region<'tcx>,
origin: SubregionOrigin<'tcx>
) -> Region<'tcx>
pub fn universe(&self, region: Region<'tcx>) -> UniverseIndex[src]
pub fn vars_since_snapshot(
&self,
value_count: usize
) -> (Range<RegionVid>, Vec<RegionVariableOrigin>)[src]
&self,
value_count: usize
) -> (Range<RegionVid>, Vec<RegionVariableOrigin>)
pub fn region_constraints_added_in_snapshot(
&self,
mark: &Snapshot<'tcx>
) -> Option<bool>[src]
&self,
mark: &Snapshot<'tcx>
) -> Option<bool>
See InferCtxt::region_constraints_added_in_snapshot.
pub(in infer::region_constraints) fn unification_table(
&mut self
) -> UnificationTable<InPlace<RegionVid, &'_ mut UnificationStorage<RegionVid>, &'_ mut InferCtxtUndoLogs<'tcx>>>[src]
&mut self
) -> UnificationTable<InPlace<RegionVid, &'_ mut UnificationStorage<RegionVid>, &'_ mut InferCtxtUndoLogs<'tcx>>>
Methods from Deref<Target = RegionConstraintStorage<'tcx>>
pub(crate) fn with_log<'a>(
&'a mut self,
undo_log: &'a mut InferCtxtUndoLogs<'tcx>
) -> RegionConstraintCollector<'a, 'tcx>[src]
&'a mut self,
undo_log: &'a mut InferCtxtUndoLogs<'tcx>
) -> RegionConstraintCollector<'a, 'tcx>
pub(in infer::region_constraints) fn rollback_undo_entry(
&mut self,
undo_entry: UndoLog<'tcx>
)[src]
&mut self,
undo_entry: UndoLog<'tcx>
)
Trait Implementations
impl<'_, 'tcx> Deref for RegionConstraintCollector<'_, 'tcx>[src]
type Target = RegionConstraintStorage<'tcx>
The resulting type after dereferencing.
pub fn deref(&self) -> &RegionConstraintStorage<'tcx>[src]
impl<'_, 'tcx> DerefMut for RegionConstraintCollector<'_, 'tcx>[src]
pub fn deref_mut(&mut self) -> &mut RegionConstraintStorage<'tcx>[src]
Auto Trait Implementations
impl<'a, 'tcx> !RefUnwindSafe for RegionConstraintCollector<'a, 'tcx>
impl<'a, 'tcx> !Send for RegionConstraintCollector<'a, 'tcx>
impl<'a, 'tcx> !Sync for RegionConstraintCollector<'a, 'tcx>
impl<'a, 'tcx> Unpin for RegionConstraintCollector<'a, 'tcx> where
'tcx: 'a,
'tcx: 'a,
impl<'a, 'tcx> !UnwindSafe for RegionConstraintCollector<'a, 'tcx>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.