Rules for Determining Place Conditions
Place conditions are computed in terms of triples, where a triple is a pair (pre, post) where pre is a place condition and post is either a place condition or None
.
The place conditions for each phase are determined by two sets of triples: the
operand triples and the main triples. The place conditions for the
PreOperands
phase is the set of conditions in the pres of the operand
triples. The PostOperands
phase is the set of conditions in the posts of the
operand triples. PreMain
and PostMain
are defined accordingly.
Determining Operand Triples for a Statement
- For each operand in the statement:
- If takes the form
copy p
:- Add
(p: R, None)
to the operand triples
- Add
- If takes the form
move p
:- Add
(p: E, p: W)
to the operand triples
- Add
- If takes the form
- For each rvalue in the statement:
- If takes the form
&p
:- Add
(p: R, p: R)
to the operand triples
- Add
- If takes the form
&mut p
:- If the borrow is a two-phase borrow:
- Add
(ExpandTwoPhase p, p: R)
to the operand triples
- Add
- Otherwise, add
(p: E, RemoveCapability p)
to the operand triples
- If the borrow is a two-phase borrow:
- If takes the form
*mut p
:- Add
(p: E, None)
to the operand triples
- Add
- If takes the form
*const p
:- Add
(p: R, None)
to the operand triples
- Add
- If takes the form
len(p)
,discriminant(p)
orCopyForDeref(p)
:- Add
(p: R, None)
to the operand triples
- Add
- If takes the form
Determining Main Triples for a Statement
The rule depends on the statement type:
Assign(p, r)
- If
r
takes the form&fake q
:- Add
(p: W, None)
to the main triples
- Add
- If
r
takes the formShallowInitBox o t
- Add
(p: W, p: e)
to the main triples
- Add
- Otherwise, add
(p: W, p: E)
to the main triples
- If
FakeRead(_, p)
- Add
(p: R, None)
to the main triples
- Add
SetDiscriminant(p, ..)
- Add
(p: E, None)
to the main triples
- Add
Deinit(p)
- Add
(p: E, p: w)
to the main triples
- Add
StorageLive(v)
- Add
(Unalloc v, AllocateOrDeallocate v)
to the main triples
- Add
StorageDead(v)
- Add
(AllocateOrDeallocate v, Unalloc v)
to the main triples
- Add
Retag(_, p)
- Add
(p: E, None)
to the main triples
- Add
Determining Main Triples for a Terminator
The rule depends on the terminator type:
Return
- Add
(Return, _0: w)
to the main triples
- Add
Drop(p)
- Add
(p: W, None)
to the main triples
- Add
Call(p, _)
- Add
(p: W, p: E)
to the main triples
- Add
Yield(p, _)
- Add
(p: W, p: E)
to the main triples
- Add