pub struct LocalId(pub u32);Expand description
Local binding identifier. Unique per function body (not per
program) — backends look up the binding by walking the body’s
Let chain, so collision across functions isn’t a concern.
Phase 2 picks “assign at MIR construction time” over “carry the HIR slot index” (the latter was the strawman alternative listed in the RFC). The carry-from-HIR option would have meant MIR’s local space matches whatever the resolver chose — fine for the VM consumer, but the future inliner / monomorphizer needs the freedom to introduce fresh locals during optimization passes, and inheriting HIR’s numbering would silently overlap with those.
Seed during Phase 3 (waves 1-3b): the lowerer seeds new
LocalIds from the resolver’s slot indices
(ResolvedExpr::Resolved { slot, .. }, FnResolution.local_slots,
ResolvedMatchArm.binding_slots) and grows synthetic locals
from local_count upward for Stmt::Expr intermediates the
resolver didn’t see. The slot space is unique per function so
reuse is safe. Later optimizer passes are still free to
renumber — LocalId is just an opaque identity per body, not
a promise about resolver lineage.
Tuple Fields§
§0: u32Trait Implementations§
impl Copy for LocalId
impl Eq for LocalId
Source§impl Ord for LocalId
impl Ord for LocalId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for LocalId
impl PartialOrd for LocalId
impl StructuralPartialEq for LocalId
Auto Trait Implementations§
impl Freeze for LocalId
impl RefUnwindSafe for LocalId
impl Send for LocalId
impl Sync for LocalId
impl Unpin for LocalId
impl UnsafeUnpin for LocalId
impl UnwindSafe for LocalId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.