Struct rustc_middle::middle::region::Scope [−][src]
pub struct Scope {
pub id: ItemLocalId,
pub data: ScopeData,
}
Expand description
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
data: ScopeData
Implementations
Returns an 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
.
Trait Implementations
type Lifted = Self
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns true
if self
has any late-bound regions that are either
bound by binder
or bound by some binder outside of binder
.
If binder
is ty::INNERMOST
, this indicates whether
there are any late-bound regions that appear free. Read more
Returns true
if this self
has any regions that escape binder
(and
hence are not bound by it). Read more
“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound. Read more
True if there are any un-erased free regions.
Indicates whether this value definitely references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
True if there are any late-bound regions
Indicates whether this value still has parameters/placeholders/inference variables
which could be replaced later, in a way that would change the results of impl
specialization. Read more
Auto Trait Implementations
impl RefUnwindSafe for Scope
impl UnwindSafe for Scope
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<Ctxt, T> DepNodeParams<Ctxt> for T where
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Ctxt, T> DepNodeParams<Ctxt> for T where
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous). Read more
This method tries to recover the query key from the given DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes