Skip to content

Commit 103b908

Browse files
Use single-element tuples in facts
...instead of bare indexes. This makes some macros easier to write.
1 parent 0cbbb7c commit 103b908

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

polonius-engine/src/facts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub struct AllFacts<T: FactTypes> {
1111
pub loan_issued_at: Vec<(T::Origin, T::Loan, T::Point)>,
1212

1313
/// `universal_region(origin)` -- this is a "free region" within fn body
14-
pub universal_region: Vec<T::Origin>,
14+
pub universal_region: Vec<(T::Origin,)>,
1515

1616
/// `cfg_edge(point1, point2)` for each edge `point1 -> point2` in the control flow
1717
pub cfg_edge: Vec<(T::Point, T::Point)>,

polonius-engine/src/output/liveness.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ pub(super) fn compute_live_origins<T: FactTypes>(
157157
pub(super) fn make_universal_regions_live<T: FactTypes>(
158158
origin_live_on_entry: &mut Vec<(T::Origin, T::Point)>,
159159
cfg_node: &BTreeSet<T::Point>,
160-
universal_regions: &[T::Origin],
160+
universal_regions: &[(T::Origin,)],
161161
) {
162162
debug!("make_universal_regions_live()");
163163

164164
origin_live_on_entry.reserve(universal_regions.len() * cfg_node.len());
165-
for &origin in universal_regions.iter() {
165+
for &(origin,) in universal_regions.iter() {
166166
for &point in cfg_node.iter() {
167167
origin_live_on_entry.push((origin, point));
168168
}

polonius-engine/src/output/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl<T: FactTypes> Output<T> {
255255
all_facts
256256
.universal_region
257257
.iter()
258-
.map(|&origin| (origin, ())),
258+
.map(|&origin| (origin.0, ())),
259259
);
260260

261261
let placeholder_loan = Relation::from_iter(

src/program.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::intern::InternerTables;
1414
#[derive(Default)]
1515
struct Facts {
1616
loan_issued_at: BTreeSet<(Origin, Loan, Point)>,
17-
universal_region: BTreeSet<Origin>,
17+
universal_region: BTreeSet<(Origin,)>,
1818
cfg_edge: BTreeSet<(Point, Point)>,
1919
loan_killed_at: BTreeSet<(Loan, Point)>,
2020
subset_base: BTreeSet<(Origin, Origin, Point)>,
@@ -72,7 +72,7 @@ pub(crate) fn parse_from_program(
7272
input
7373
.placeholders
7474
.iter()
75-
.map(|placeholder| tables.origins.intern(&placeholder.origin)),
75+
.map(|placeholder| (tables.origins.intern(&placeholder.origin),)),
7676
);
7777

7878
// facts: placeholder(Origin, Loan)
@@ -296,7 +296,7 @@ mod tests {
296296
let universal_regions: Vec<_> = facts
297297
.universal_region
298298
.iter()
299-
.map(|origin| tables.origins.untern(*origin))
299+
.map(|origin| tables.origins.untern(origin.0))
300300
.collect();
301301
assert_eq!(universal_regions, ["'a", "'b", "'c"]);
302302

src/tab_delim.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,19 @@ where
9090
}
9191
}
9292

93+
impl<'input, T> FromTabDelimited<'input> for (T,)
94+
where
95+
&'input str: InternTo<T>,
96+
{
97+
fn parse(
98+
tables: &mut InternerTables,
99+
inputs: &mut dyn Iterator<Item = &'input str>,
100+
) -> Option<Self> {
101+
let input = inputs.next()?;
102+
Some((InternTo::intern(tables, input),))
103+
}
104+
}
105+
93106
impl<'input, T> FromTabDelimited<'input> for T
94107
where
95108
&'input str: InternTo<T>,

0 commit comments

Comments
 (0)