Skip to main content

LambdaEscapeSlot

Struct LambdaEscapeSlot 

Source
pub struct LambdaEscapeSlot {
    pub range: TextRange,
    pub ty: Ty,
    pub annotated: bool,
    pub slot_label: String,
}
Expand description

One lambda-body param or body-declared temp, ready for the same Unknown-escape (E065) / Conflicted-escape (E066) treatment strict::check_def already gives a top-level def’s own params/ locals (issue #1770: “lambda bodies are invisible to strict-mode escape checking… give lambda bodies a per-lambda frame”).

A lambda literal still has no DefinitionId-keyed BodyTypes entry of its own to run check_def against — #1727 minted a lifted lambda a stable identity, not a SymbolIndex entry / DefKey (see that issue’s ruling), and infer_project/InferPass run over HIR straight from hir::lower, strictly before hir::stamp_container_ids (which only runs as part of LIR lowering / the normalized_stamped_query salsa memo) — so even the identity #1727 does mint is not populated yet at the point this fact is recorded. Building a per-lambda strict-frame does not need it: each slot below is already a fully self-contained emit_escape input (final type, declaration range, annotation-exemption bit, and a ready-made slot label), so strict::check_def re-emits it with no per-lambda grouping or lookup required.

Recorded unconditionally by [body::InferPass::infer_lambda] for every lambda anywhere in the enclosing def’s body, including one nested inside another lambda’s own body — each nested lambda gets its own infer_lambda call and so contributes its own slots to this same flat, cumulative vector (mirrors LambdaAnnotationMismatch’s identical “folded in from every lambda anywhere in this body” precedent). Reported only by strict mode.

Deliberately excludes a lambda’s own return-type slot: unlike a top-level fn’s return-type escape check, “does this lambda’s body ever return a value” has no E150-style fall-through analysis defined for it, and #1994’s LambdaAnnotationMismatch (E174) already owns a materially different, eager check for a lambda’s return-type annotation disagreeing with its body — adding a second, gradual escape check for the identical slot would double-report the same fact under a different code. Out of scope for #1770; see that issue’s own “Ask” (params + temps only, matching BodyTypes::locals’s own params-∪-temps membership, not BodyTypes::return_ty).

Fields§

§range: TextRange

The slot’s own declaration range — a param’s name range, or a body-declared temp’s/if-as-binding’s/for-var’s own name range. The diagnostic anchor, same convention as check_def’s own per-slot ranges.

§ty: Ty

The slot’s final, escape-checked type.

§annotated: bool

Whether a resolvable annotation/ascription exempts an Unknown classification (never a Conflicted one) — mirrors check_def’s own annotated argument to emit_escape. Always false for a param slot: infer_lambda’s own annotation-governs-when-present overlay (#1994) already replaces an annotated param’s ty with the resolved annotation itself before this slot is built, so there is nothing left for a separate exemption to do there — this field only ever does real work for a body-declared temp, which carries no such overlay.

That holds only for a param whose name the lambda’s own body never re-binds. A name the body does re-bind (|t: int| { let t = 1; t = "oops"; t }) never reaches a param slot at all — review finding on #1770: the governance overlay’s rebound-name branch reads ty straight from self.locals[name], i.e. the shadowing local’s own accumulated type, not the annotated param’s, so infer_lambda excludes that name from this loop entirely and reports it only as a "lambda temp" slot instead (built from the same body-declared- temps loop every ordinary temp goes through) — the escape belongs to the fresh local, not the parameter of the same spelling.

§slot_label: String

The slot’s own label, ready to hand straight to emit_escape — e.g. "lambda parameter `x`" / "lambda temp `t`" — prefixed so the reported message reads distinctly from the enclosing def’s own same-named slot (check_def’s param_name and slot_label convention, one level in).

Trait Implementations§

Source§

impl Clone for LambdaEscapeSlot

Source§

fn clone(&self) -> LambdaEscapeSlot

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 LambdaEscapeSlot

Source§

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

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

impl Eq for LambdaEscapeSlot

Source§

impl PartialEq for LambdaEscapeSlot

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LambdaEscapeSlot

Auto Trait Implementations§

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
Source§

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

Source§

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

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

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

Source§

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

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

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

Source§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more