Struct rustc::mir::LocalDecl
[−]
[src]
pub struct LocalDecl<'tcx> { pub mutability: Mutability, pub is_user_variable: bool, pub internal: bool, pub ty: Ty<'tcx>, pub name: Option<Name>, pub source_info: SourceInfo, pub syntactic_scope: VisibilityScope, }
🔬 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?
A MIR local.
This can be a binding declared by the user, a temporary inserted by the compiler, a function argument, or the return place.
Fields
mutability: Mutability
🔬 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?
let mut x
vs let x
.
Temporaries and the return place are always mutable.
is_user_variable: 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 corresponds to a user-declared local variable.
internal: 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 is an internal local
These locals are not based on types in the source code and are only used for a few desugarings at the moment.
The generator transformation will sanity check the locals which are live across a suspension point against the type components of the generator which type checking knows are live across a suspension point. We need to flag drop flags to avoid triggering this check as they are introduced after typeck.
Unsafety checking will also ignore dereferences of these locals, so they can be used for raw pointers only used in a desugaring.
This should be sound because the drop flags are fully algebraic, and therefore don't affect the OIBIT or outlives properties of the generator.
ty: Ty<'tcx>
🔬 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?
Type of this local.
name: Option<Name>
🔬 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?
Name of the local, used in debuginfo and pretty-printing.
Note that function arguments can also have this set to Some(_)
to generate better debuginfo.
source_info: SourceInfo
🔬 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?
Source info of the local.
syntactic_scope: VisibilityScope
🔬 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?
The syntactic visibility scope the local is defined in. If the local was defined in a let-statement, this is within the let-statement, rather than outside of it.
This is needed because visibility scope of locals within a let-statement is weird.
The reason is that we want the local to be within the let-statement for lint purposes, but we want the local to be after the let-statement for names-in-scope purposes.
That's it, if we have a let-statement like the one in this function:
fn foo(x: &str) { #[allow(unused_mut)] let mut x: u32 = { // <- one unused mut let mut y: u32 = x.parse().unwrap(); y + 2 }; drop(x); }
Then, from a lint point of view, the declaration of x: u32
(and y: u32
) are within the #[allow(unused_mut)]
scope - the
lint scopes are the same as the AST/HIR nesting.
However, from a name lookup point of view, the scopes look more like
as if the let-statements were match
expressions:
fn foo(x: &str) { match { match x.parse().unwrap() { y => y + 2 } } { x => drop(x) }; }
We care about the name-lookup scopes for debuginfo - if the
debuginfo instruction pointer is at the call to x.parse()
, we
want x
to refer to x: &str
, but if it is at the call to
drop(x)
, we want it to refer to x: u32
.
To allow both uses to work, we need to have more than a single scope
for a local. We have the syntactic_scope
represent the
"syntactic" lint scope (with a variable being under its let
block) while the source-info scope represents the "local variable"
scope (where the "rest" of a block is under all prior let-statements).
The end result looks like this:
ROOT SCOPE
│{ argument x: &str }
│
│ │{ #[allow(unused_mut] } // this is actually split into 2 scopes
│ │ // in practice because I'm lazy.
│ │
│ │← x.syntactic_scope
│ │← `x.parse().unwrap()`
│ │
│ │ │← y.syntactic_scope
│ │
│ │ │{ let y: u32 }
│ │ │
│ │ │← y.source_info.scope
│ │ │← `y + 2`
│
│ │{ let x: u32 }
│ │← x.source_info.scope
│ │← `drop(x)` // this accesses `x: u32`
Methods
impl<'tcx> LocalDecl<'tcx>
[src]
impl<'tcx> LocalDecl<'tcx>
pub fn new_temp(ty: Ty<'tcx>, span: Span) -> Self
[src]
pub fn new_temp(ty: Ty<'tcx>, span: Span) -> 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?
Create a new LocalDecl
for a temporary.
pub fn new_internal(ty: Ty<'tcx>, span: Span) -> Self
[src]
pub fn new_internal(ty: Ty<'tcx>, span: Span) -> 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?
Create a new LocalDecl
for a internal temporary.
pub fn new_return_place(return_ty: Ty, span: Span) -> LocalDecl
[src]
pub fn new_return_place(return_ty: Ty, span: Span) -> LocalDecl
🔬 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?
Builds a LocalDecl
for the return place.
This must be inserted into the local_decls
list as the first local.
Trait Implementations
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for LocalDecl<'tcx>
[src]
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for LocalDecl<'tcx>
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<'tcx> Clone for LocalDecl<'tcx>
[src]
impl<'tcx> Clone for LocalDecl<'tcx>
fn clone(&self) -> LocalDecl<'tcx>
[src]
fn clone(&self) -> LocalDecl<'tcx>
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<'tcx> Debug for LocalDecl<'tcx>
[src]
impl<'tcx> Debug for LocalDecl<'tcx>
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'tcx> Encodable for LocalDecl<'tcx>
[src]
impl<'tcx> Encodable for LocalDecl<'tcx>
fn encode<__S: Encoder>(&self, __arg_0: &mut __S) -> Result<(), __S::Error>
[src]
fn encode<__S: Encoder>(&self, __arg_0: &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<'tcx> Decodable for LocalDecl<'tcx>
[src]
impl<'tcx> Decodable for LocalDecl<'tcx>
fn decode<__D: Decoder>(
__arg_0: &mut __D
) -> Result<LocalDecl<'tcx>, __D::Error>
[src]
fn decode<__D: Decoder>(
__arg_0: &mut __D
) -> Result<LocalDecl<'tcx>, __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<'tcx> TypeFoldable<'tcx> for LocalDecl<'tcx>
[src]
impl<'tcx> TypeFoldable<'tcx> for LocalDecl<'tcx>
fn super_fold_with<'gcx: 'tcx, V: TypeFolder<'gcx, 'tcx>>(
&self,
folder: &mut V
) -> Self
[src]
fn super_fold_with<'gcx: 'tcx, V: TypeFolder<'gcx, 'tcx>>(
&self,
folder: &mut V
) -> 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 super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool
[src]
fn super_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 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_escaping_depth(&self, depth: u32) -> bool
[src]
fn has_regions_escaping_depth(&self, depth: u32) -> 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_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 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_normalized_for_trans(&self) -> bool
[src]
fn is_normalized_for_trans(&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 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. Errs on the side of returning false. Read more