Skip to content

Commit b70898d

Browse files
Improve docs for GenKill and GenKillSet
1 parent 2727f10 commit b70898d

File tree

1 file changed

+8
-6
lines changed
  • src/librustc_mir/dataflow/generic

1 file changed

+8
-6
lines changed

src/librustc_mir/dataflow/generic/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -273,21 +273,19 @@ where
273273
}
274274

275275
/// The legal operations for a transfer function in a gen/kill problem.
276-
pub trait GenKill<T>: Sized {
277-
/// Inserts `elem` into the `gen` set, removing it the `kill` set if present.
276+
pub trait GenKill<T> {
277+
/// Inserts `elem` into the state vector.
278278
fn gen(&mut self, elem: T);
279279

280-
/// Inserts `elem` into the `kill` set, removing it the `gen` set if present.
280+
/// Removes `elem` from the state vector.
281281
fn kill(&mut self, elem: T);
282282

283-
/// Inserts the given elements into the `gen` set, removing them from the `kill` set if present.
284283
fn gen_all(&mut self, elems: impl IntoIterator<Item = T>) {
285284
for elem in elems {
286285
self.gen(elem);
287286
}
288287
}
289288

290-
/// Inserts the given elements into the `kill` set, removing them from the `gen` set if present.
291289
fn kill_all(&mut self, elems: impl IntoIterator<Item = T>) {
292290
for elem in elems {
293291
self.kill(elem);
@@ -296,6 +294,10 @@ pub trait GenKill<T>: Sized {
296294
}
297295

298296
/// Stores a transfer function for a gen/kill problem.
297+
///
298+
/// Calling `gen`/`kill` on a `GenKillSet` will "build up" a transfer function so that it can be
299+
/// applied to a state vector efficiently. When there are multiple calls to `gen` and/or `kill` for
300+
/// the same element, the most recent one takes precedence.
299301
#[derive(Clone)]
300302
pub struct GenKillSet<T: Idx> {
301303
gen: HybridBitSet<T>,
@@ -311,7 +313,7 @@ impl<T: Idx> GenKillSet<T> {
311313
}
312314
}
313315

314-
/// Applies this transfer function to the given bitset.
316+
/// Applies this transfer function to the given state vector.
315317
pub fn apply(&self, state: &mut BitSet<T>) {
316318
state.union(&self.gen);
317319
state.subtract(&self.kill);

0 commit comments

Comments
 (0)