[][src]Struct rustc::middle::region::Scope

pub struct Scope {
    pub id: ItemLocalId,
    pub data: ScopeData,
}
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Represents a statically-describable scope that can be used to bound the lifetime/region for values.

Node(node_id): Any AST node that has any scope at all has the Node(node_id) scope. Other variants represent special cases not immediately derivable from the abstract syntax tree structure.

DestructionScope(node_id) represents the scope of destructors implicitly-attached to node_id that run immediately after the expression for node_id itself. Not every AST node carries a DestructionScope, but those that are terminating_scopes do; see discussion with ScopeTree.

Remainder { block, statement_index } represents the scope of user code running immediately after the initializer expression for the indexed statement, until the end of the block.

So: the following code can be broken down into the scopes beneath:

let a = f().g( 'b: { let x = d(); let y = d(); x.h(y)  }   ) ;

                                                             +-+ (D12.)
                                                       +-+       (D11.)
                                             +---------+         (R10.)
                                             +-+                  (D9.)
                                  +----------+                    (M8.)
                                +----------------------+          (R7.)
                                +-+                               (D6.)
                     +----------+                                 (M5.)
                   +-----------------------------------+          (M4.)
        +--------------------------------------------------+      (M3.)
        +--+                                                      (M2.)
+-----------------------------------------------------------+     (M1.)

 (M1.): Node scope of the whole `let a = ...;` statement.
 (M2.): Node scope of the `f()` expression.
 (M3.): Node scope of the `f().g(..)` expression.
 (M4.): Node scope of the block labeled `'b:`.
 (M5.): Node scope of the `let x = d();` statement
 (D6.): DestructionScope for temporaries created during M5.
 (R7.): Remainder scope for block `'b:`, stmt 0 (let x = ...).
 (M8.): Node scope of the `let y = d();` statement.
 (D9.): DestructionScope for temporaries created during M8.
(R10.): Remainder scope for block `'b:`, stmt 1 (let y = ...).
(D11.): DestructionScope for temporaries and bindings from block `'b:`.
(D12.): DestructionScope for temporaries created during M1 (e.g., f()).

Note that while the above picture shows the destruction scopes as following their corresponding node scopes, in the internal data structures of the compiler the destruction scopes are represented as enclosing parents. This is sound because we use the enclosing parent relationship just to ensure that referenced values live long enough; phrased another way, the starting point of each range is not really the important thing in the above picture, but rather the ending point.

Fields

id: ItemLocalId
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

data: ScopeData
⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Methods

impl Scope[src]

pub fn item_local_id(&self) -> ItemLocalId[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Returns a item-local ID associated with this scope.

N.B., likely to be replaced as API is refined; e.g., pnkfelix anticipates fn entry_node_id and fn each_exit_node_id.

pub fn hir_id(&self, scope_tree: &ScopeTree) -> HirId[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

pub fn span(&self, tcx: TyCtxt, scope_tree: &ScopeTree) -> Span[src]

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

Returns the span of this Scope. Note that in general the returned span may not correspond to the span of any NodeId in the AST.

Trait Implementations

impl Clone for Scope[src]

impl Copy for Scope[src]

impl Debug for Scope[src]

impl Decodable for Scope[src]

impl Encodable for Scope[src]

impl Eq for Scope[src]

impl Hash for Scope[src]

impl<'__ctx> HashStable<StableHashingContext<'__ctx>> for Scope[src]

impl<'tcx> Lift<'tcx> for Scope[src]

type Lifted = Self

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl Ord for Scope[src]

impl PartialEq<Scope> for Scope[src]

impl PartialOrd<Scope> for Scope[src]

impl StructuralEq for Scope[src]

impl StructuralPartialEq for Scope[src]

impl<'a> ToStableHashKey<StableHashingContext<'a>> for Scope[src]

type KeyType = Scope

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<'tcx> TypeFoldable<'tcx> for Scope[src]

Auto Trait Implementations

impl RefUnwindSafe for Scope

impl Send for Scope

impl Sync for Scope

impl Unpin for Scope

impl UnwindSafe for Scope

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ArenaAllocatable for T where
    T: Copy
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Decodable for T where
    T: UseSpecializedDecodable
[src]

impl<T> Encodable for T where
    T: UseSpecializedEncodable + ?Sized
[src]

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

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeResult<T> for T[src]

type Error = !

⚙️ This is an internal compiler API. (rustc_private)

This crate is being loaded from the sysroot, a permanently unstable location for private compiler dependencies. It is not intended for general use. Prefer using a public version of this crate from crates.io via Cargo.toml.

impl<E> SpecializationError for E[src]

impl<'tcx, T> Subst<'tcx> for T where
    T: TypeFoldable<'tcx>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]