flow-span 0.1.0-rc.5

Source positions, source files, the identifier interner, and the places in a run.
Documentation
//! Typed indices and the containers keyed by them.
//!
//! Every phase artifact in this workspace stores its nodes in a flat
//! [`IndexVec`] and names them by a typed index rather than by a pointer or a
//! hash key. That single decision buys four things at once:
//!
//! - **A node has one name.** [`IndexVec::push`] returns the index it just
//!   assigned, so a producer never has to guess or recompute a node's identity.
//! - **The names are cheap and total.** An index is a `u32`, is `Copy`, and
//!   carries no lifetime, so a side table is an ordinary `IndexVec` keyed by the
//!   same index instead of a map with a hasher and an iteration order.
//! - **The names do not mix.** `newtype_index!` mints a distinct type per
//!   domain, so passing a `BlockId` where an `ExprId` belongs is a compile
//!   error rather than a silent out-of-bounds read.
//! - **Iteration order is positional.** Canonical order is *semantic* in Flow —
//!   it reaches encodings, digests, and semantic history — so a container whose
//!   order comes from a hash seed may never stand between a program and a
//!   recorded fact. An `IndexVec` has no order to leak.
//!
//! # What is deliberately absent
//!
//! There is no borrowed `IndexSlice`. Producing one from a `&[T]` without a
//! transmute is not possible, and this workspace forbids `unsafe`. Code that
//! needs a sub-range takes a plain `&[T]`; code that needs indexed access takes
//! `&IndexVec`. The type that would have made that distinction ergonomic is not
//! worth an `unsafe` block here.
//!
//! There is no niche-optimized index either, for the same reason: reserving
//! `u32::MAX` as an invalid discriminant needs `unsafe` to be free, so
//! `Option<SomeId>` is eight bytes and that is fine.

mod idx;
#[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod test_index;
mod vec;

pub use idx::{Idx, MAX_INDEX};
pub use vec::IndexVec;