Skip to content

Commit 6d5a9ee

Browse files
committed
cool
1 parent 6baaf60 commit 6d5a9ee

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/table_collection.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,10 +1756,14 @@ impl TableCollection {
17561756
}
17571757

17581758
// convert sys version of tables to non-sys version of tables
1759-
let new_edges = EdgeTable::new_from_table(new_edges.as_mut())?;
1760-
let new_migrations = MigrationTable::new_from_table(new_migrations.as_mut())?;
1761-
let new_mutations = MutationTable::new_from_table(new_mutations.as_mut())?;
1762-
let new_sites = SiteTable::new_from_table(new_sites.as_mut())?;
1759+
// SAFETY: all the casts to *mut Foo are coming in via an implicit
1760+
// cast from &mut Foo, which means that the ptr cannot be NULL.
1761+
// Further, all input tables are initialized.
1762+
// Finally, none of these variables will be every be pub.
1763+
let new_edges = unsafe { EdgeTable::new_from_table(new_edges.as_mut())? };
1764+
let new_migrations = unsafe { MigrationTable::new_from_table(new_migrations.as_mut())? };
1765+
let new_mutations = unsafe { MutationTable::new_from_table(new_mutations.as_mut())? };
1766+
let new_sites = unsafe { SiteTable::new_from_table(new_sites.as_mut())? };
17631767

17641768
// replace old tables with new tables
17651769
tables.set_edges(&new_edges).map(|_| ())?;

0 commit comments

Comments
 (0)