Struct rustc::middle::region::Scope [−][src]
pub struct Scope { pub(crate) id: ItemLocalId, pub(crate) code: u32, }
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Scope 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(BlockRemainder { 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.
FIXME (pnkfelix): This currently derives PartialOrd
and Ord
to
placate the same deriving in ty::FreeRegion
, but we may want to
actually attach a more meaningful ordering to scopes than the one
generated via deriving here.
Scope is a bit-packed to save space - if code
is SCOPE_DATA_REMAINDER_MAX
or less, it is a ScopeData::Remainder
, otherwise it is a type specified
by the bitpacking.
Fields
id: ItemLocalId
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
code: u32
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Methods
impl Scope
[src]
impl Scope
pub fn data(self) -> ScopeData
[src]
pub fn data(self) -> ScopeData
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn Node(id: ItemLocalId) -> Self
[src]
pub fn Node(id: ItemLocalId) -> Self
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn CallSite(id: ItemLocalId) -> Self
[src]
pub fn CallSite(id: ItemLocalId) -> Self
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn Arguments(id: ItemLocalId) -> Self
[src]
pub fn Arguments(id: ItemLocalId) -> Self
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn Destruction(id: ItemLocalId) -> Self
[src]
pub fn Destruction(id: ItemLocalId) -> Self
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn Remainder(r: BlockRemainder) -> Self
[src]
pub fn Remainder(r: BlockRemainder) -> Self
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl Scope
[src]
impl Scope
pub fn item_local_id(&self) -> ItemLocalId
[src]
pub fn item_local_id(&self) -> ItemLocalId
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns a item-local id associated with this scope.
NB: likely to be replaced as API is refined; e.g. pnkfelix
anticipates fn entry_node_id
and fn each_exit_node_id
.
pub fn node_id(&self, tcx: TyCtxt, scope_tree: &ScopeTree) -> NodeId
[src]
pub fn node_id(&self, tcx: TyCtxt, scope_tree: &ScopeTree) -> NodeId
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn span(&self, tcx: TyCtxt, scope_tree: &ScopeTree) -> Span
[src]
pub fn span(&self, tcx: TyCtxt, scope_tree: &ScopeTree) -> Span
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns the span of this Scope. Note that in general the returned span may not correspond to the span of any node id in the AST.
Trait Implementations
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Scope
[src]
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Scope
fn hash_stable<W: StableHasherResult>(
&self,
__ctx: &mut StableHashingContext<'a>,
__hasher: &mut StableHasher<W>
)
[src]
fn hash_stable<W: StableHasherResult>(
&self,
__ctx: &mut StableHashingContext<'a>,
__hasher: &mut StableHasher<W>
)
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl<'a> ToStableHashKey<StableHashingContext<'a>> for Scope
[src]
impl<'a> ToStableHashKey<StableHashingContext<'a>> for Scope
type KeyType = Scope
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn to_stable_hash_key(&self, _: &StableHashingContext<'a>) -> Scope
[src]
fn to_stable_hash_key(&self, _: &StableHashingContext<'a>) -> Scope
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl Clone for Scope
[src]
impl Clone for Scope
fn clone(&self) -> Scope
[src]
fn clone(&self) -> Scope
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Scope
[src]
impl PartialEq for Scope
fn eq(&self, other: &Scope) -> bool
[src]
fn eq(&self, other: &Scope) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Scope) -> bool
[src]
fn ne(&self, other: &Scope) -> bool
This method tests for !=
.
impl PartialOrd for Scope
[src]
impl PartialOrd for Scope
fn partial_cmp(&self, other: &Scope) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Scope) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Scope) -> bool
[src]
fn lt(&self, other: &Scope) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Scope) -> bool
[src]
fn le(&self, other: &Scope) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Scope) -> bool
[src]
fn gt(&self, other: &Scope) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Scope) -> bool
[src]
fn ge(&self, other: &Scope) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Eq for Scope
[src]
impl Eq for Scope
fn assert_receiver_is_total_eq(&self)
[src]
fn assert_receiver_is_total_eq(&self)
impl Ord for Scope
[src]
impl Ord for Scope
fn cmp(&self, other: &Scope) -> Ordering
[src]
fn cmp(&self, other: &Scope) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Hash for Scope
[src]
impl Hash for Scope
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Copy for Scope
[src]
impl Copy for Scope
impl Encodable for Scope
[src]
impl Encodable for Scope
fn encode<__S: Encoder>(&self, s: &mut __S) -> Result<(), __S::Error>
[src]
fn encode<__S: Encoder>(&self, s: &mut __S) -> Result<(), __S::Error>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl Decodable for Scope
[src]
impl Decodable for Scope
fn decode<__D: Decoder>(d: &mut __D) -> Result<Scope, __D::Error>
[src]
fn decode<__D: Decoder>(d: &mut __D) -> Result<Scope, __D::Error>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
impl From<ScopeData> for Scope
[src]
impl From<ScopeData> for Scope
impl Debug for Scope
[src]
impl Debug for Scope
fn fmt(&self, formatter: &mut Formatter) -> Result
[src]
fn fmt(&self, formatter: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'tcx> TypeFoldable<'tcx> for Scope
[src]
impl<'tcx> TypeFoldable<'tcx> for Scope
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(
&self,
_: &mut F
) -> Scope
[src]
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(
&self,
_: &mut F
) -> Scope
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn super_visit_with<F: TypeVisitor<'tcx>>(&self, _: &mut F) -> bool
[src]
fn super_visit_with<F: TypeVisitor<'tcx>>(&self, _: &mut F) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(
&self,
folder: &mut F
) -> Self
[src]
fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(
&self,
folder: &mut F
) -> Self
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool
[src]
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_regions_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
[src]
fn has_regions_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
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
fn has_regions_bound_above(&self, binder: DebruijnIndex) -> bool
[src]
fn has_regions_bound_above(&self, binder: DebruijnIndex) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
True if this self
has any regions that escape binder
(and hence are not bound by it). Read more
fn has_escaping_regions(&self) -> bool
[src]
fn has_escaping_regions(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_type_flags(&self, flags: TypeFlags) -> bool
[src]
fn has_type_flags(&self, flags: TypeFlags) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_projections(&self) -> bool
[src]
fn has_projections(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn references_error(&self) -> bool
[src]
fn references_error(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_param_types(&self) -> bool
[src]
fn has_param_types(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_self_ty(&self) -> bool
[src]
fn has_self_ty(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_infer_types(&self) -> bool
[src]
fn has_infer_types(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn needs_infer(&self) -> bool
[src]
fn needs_infer(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_skol(&self) -> bool
[src]
fn has_skol(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn needs_subst(&self) -> bool
[src]
fn needs_subst(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_re_skol(&self) -> bool
[src]
fn has_re_skol(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_closure_types(&self) -> bool
[src]
fn has_closure_types(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn has_free_regions(&self) -> bool
[src]
fn has_free_regions(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
"Free" regions in this context means that it has any region that is not (a) erased or (b) late-bound. Read more
fn has_erasable_regions(&self) -> bool
[src]
fn has_erasable_regions(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
True if there any any un-erased free regions.
fn is_global(&self) -> bool
[src]
fn is_global(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Indicates whether this value references only 'global' types/lifetimes that are the same regardless of what fn we are in. This is used for caching. Read more
fn has_late_bound_regions(&self) -> bool
[src]
fn has_late_bound_regions(&self) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
True if there are any late-bound regions
impl<'tcx> Lift<'tcx> for Scope
[src]
impl<'tcx> Lift<'tcx> for Scope
type Lifted = Self
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn lift_to_tcx<'a, 'gcx>(&self, _: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self>
[src]
fn lift_to_tcx<'a, 'gcx>(&self, _: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?