Skip to main content

Local

Struct Local 

Source
pub struct Local {
    pub name: Arc<str>,
    pub slot: Slot,
    pub layout: LayoutId,
    pub from: Pc,
    pub to: Pc,
}
Expand description

One named binding, and the range of the function’s code over which that name denotes that slot.

A side table, and read for the same reason Function::spans is: a name is wanted when a human asks what a frame holds — a debugger stopped at a breakpoint, issue #241 — and never in the dispatch loop, so it belongs beside the code rather than in it.

It exists because neither half of that question is answerable from the frame. Function::reprs says what a slot’s word holds, for the whole function, and that is all it says: until this table the only name anywhere in a lowered program was Capture::name, parameters were positional and locals were anonymous. So a debugger could say s7:int = 3, which is true of the machine and can be a lie about the program.

§Two locals may share a slot, and that is the point

Function::reprs’ own note says a slot may be reused by a later value of the same Repr, because the lowering hands a dead run to the next value that asks for that shape. One slot is therefore several source variables over a function’s life, and nothing but this table can tell them apart. Two locals of one slot have disjoint ranges and, usually, different names.

§Two locals may share a name

Shadowing is recorded, not resolved. let x = 1; let x = "two" is two bindings and both are kept, because the first is still what the frame holds at every pc before the second — and because resolving here would make the table disagree with the lowering, whose scope is searched backwards so that the latest declaration wins. Their ranges may overlap and their slots differ. A reader keeps the locals whose range contains the pc and takes the last match; Function::local_at is that rule written down.

A break or a continue is not an end of a range. [from, to) is an interval of program counters, every pc inside a scope’s body is one the binding is live at, and the pc a break jumps to is outside the interval already.

Fields§

§name: Arc<str>§slot: Slot§layout: LayoutId§from: Pc

The first pc at which the name is bound.

§to: Pc

One past the last. [from, to) is a half-open interval, like a Span.

Trait Implementations§

Source§

impl Clone for Local

Source§

fn clone(&self) -> Local

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Local

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Local

Source§

impl PartialEq for Local

Source§

fn eq(&self, other: &Local) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Local

Auto Trait Implementations§

§

impl Freeze for Local

§

impl RefUnwindSafe for Local

§

impl Send for Local

§

impl Sync for Local

§

impl Unpin for Local

§

impl UnsafeUnpin for Local

§

impl UnwindSafe for Local

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.