-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathfacts.rs
87 lines (69 loc) · 3 KB
/
facts.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use std::fmt::Debug;
use std::hash::Hash;
/// The "facts" which are the basis of the NLL borrow analysis.
#[derive(Clone, Debug)]
pub struct AllFacts<R: Atom, L: Atom, P: Atom, V: Atom, M: Atom> {
/// `borrow_region(R, B, P)` -- the region R may refer to data
/// from borrow B starting at the point P (this is usually the
/// point *after* a borrow rvalue)
pub borrow_region: Vec<(R, L, P)>,
/// `universal_region(R)` -- this is a "free region" within fn body
pub universal_region: Vec<R>,
/// `cfg_edge(P,Q)` for each edge P -> Q in the control flow
pub cfg_edge: Vec<(P, P)>,
/// `killed(B,P)` when some prefix of the path borrowed at B is assigned at point P
pub killed: Vec<(L, P)>,
/// `outlives(R1, R2, P)` when we require `R1@P: R2@P`
pub outlives: Vec<(R, R, P)>,
/// `region_live_at(R, P)` when the region R appears in a live variable at P
pub region_live_at: Vec<(R, P)>,
/// `invalidates(P, L)` when the loan L is invalidated at point P
pub invalidates: Vec<(P, L)>,
/// `var_used(V, P) when the variable V is used for anything but a drop at point P`
pub var_used: Vec<(V, P)>,
/// `var_defined(V, P) when the variable V is overwritten by the point P`
pub var_defined: Vec<(V, P)>,
/// `var_used(V, P) when the variable V is used in a drop at point P`
pub var_drop_used: Vec<(V, P)>,
/// `var_uses_region(V, R) when the type of V includes the region R`
pub var_uses_region: Vec<(V, R)>,
/// `var_drops_region(V, R) when the type of V includes the region R and uses
/// it when dropping`
pub var_drops_region: Vec<(V, R)>,
/// `child(M1, M2) when the move path `M1` is the child of `M2`.
pub child: Vec<(M, M)>,
/// `path_belongs_to_var(M, V) when the move path `M` starts in variable `V`.
pub path_belongs_to_var: Vec<(M, V)>,
/// `initialized_at(M, P) when the move path `M` was initialized at point
/// `P`.
pub initialized_at: Vec<(M, P)>,
/// `moved_out_at(M, P) when the move path `M` was moved at point `P`.
pub moved_out_at: Vec<(M, P)>,
}
impl<R: Atom, L: Atom, P: Atom, V: Atom, M: Atom> Default for AllFacts<R, L, P, V, M> {
fn default() -> Self {
AllFacts {
borrow_region: Vec::default(),
universal_region: Vec::default(),
cfg_edge: Vec::default(),
killed: Vec::default(),
outlives: Vec::default(),
region_live_at: Vec::default(),
invalidates: Vec::default(),
var_used: Vec::default(),
var_defined: Vec::default(),
var_drop_used: Vec::default(),
var_uses_region: Vec::default(),
var_drops_region: Vec::default(),
child: Vec::default(),
path_belongs_to_var: Vec::default(),
initialized_at: Vec::default(),
moved_out_at: Vec::default(),
}
}
}
pub trait Atom:
From<usize> + Into<usize> + Copy + Clone + Debug + Eq + Ord + Hash + 'static
{
fn index(self) -> usize;
}