Struct rustc::mir::LocalDecl [−][src]
pub struct LocalDecl<'tcx> { pub mutability: Mutability, pub is_user_variable: Option<ClearCrossCrate<BindingForm>>, pub internal: bool, pub ty: Ty<'tcx>, pub name: Option<Name>, pub source_info: SourceInfo, pub visibility_scope: SourceScope, }
🔬 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: Option<ClearCrossCrate<BindingForm>>
🔬 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?
Some(binding_mode) if this corresponds to a user-declared local variable.
This is solely used for local diagnostics when generating
warnings/errors when compiling the current crate, and
therefore it need not be visible across crates. pnkfelix
currently hypothesized we need to wrap this in a
ClearCrossCrate
as long as it carries as HirId
.
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?
The syntactic (i.e. not visibility) source 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 the visibility source 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 source_info.scope
represent the
"syntactic" lint scope (with a variable being under its let
block) while the visibility_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.source_info.scope
│ │← `x.parse().unwrap()`
│ │
│ │ │← y.source_info.scope
│ │
│ │ │{ let y: u32 }
│ │ │
│ │ │← y.visibility_scope
│ │ │← `y + 2`
│
│ │{ let x: u32 }
│ │← x.visibility_scope
│ │← `drop(x)` // this accesses `x: u32`
visibility_scope: SourceScope
🔬 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 scope within which the local is visible (for debuginfo)
(see source_info
for more details).
Methods
impl<'tcx> LocalDecl<'tcx>
[src]
impl<'tcx> LocalDecl<'tcx>
pub fn can_be_made_mutable(&self) -> bool
[src]
pub fn can_be_made_mutable(&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?
Returns true only if local is a binding that can itself be
made mutable via the addition of the mut
keyword, namely
something like the occurrences of x
in:
fn foo(x: Type) { ... }
,let x = ...
,- or
match ... { C(x) => ... }
pub fn is_nonref_binding(&self) -> bool
[src]
pub fn is_nonref_binding(&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?
Returns true if local is definitely not a ref ident
or
ref mut ident
binding. (Such bindings cannot be made into
mutable bindings, but the inverse does not necessarily hold).
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, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &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, 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<'tcx> Decodable for LocalDecl<'tcx>
[src]
impl<'tcx> Decodable for LocalDecl<'tcx>
fn decode<__D: Decoder>(d: &mut __D) -> Result<LocalDecl<'tcx>, __D::Error>
[src]
fn decode<__D: Decoder>(d: &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_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