Expand description
See docs in build/expr/mod.rs
Re-exportsΒ§
use std::assert_matches;πuse std::iter;πuse rustc_abi::FIRST_VARIANT;πuse rustc_abi::FieldIdx;πuse rustc_abi::VariantIdx;πuse rustc_hir::def_id::LocalDefId;πuse rustc_middle::hir::place::Projection as HirProjection;πuse rustc_middle::hir::place::ProjectionKind as HirProjectionKind;πuse rustc_middle::mir::AssertKind::BoundsCheck;πuse rustc_middle::ty;πuse rustc_middle::ty::AdtDef;πuse rustc_middle::ty::CanonicalUserTypeAnnotation;πuse rustc_middle::ty::Ty;πuse rustc_middle::ty::Variance;πuse rustc_span::Span;πuse rustc_span::bug;πuse rustc_span::span_bug;πuse tracing::debug;πuse tracing::instrument;πuse tracing::instrument;πuse tracing::trace;πuse crate::builder::ForGuard::OutsideGuard;πuse crate::builder::ForGuard::RefWithinGuard;πuse crate::builder::expr::category::Category;πuse crate::builder::scope::LintLevel;πuse crate::builder::BlockAnd;πuse crate::builder::BlockAndExtension;πuse crate::builder::Builder;πuse crate::builder::Capture;πuse crate::builder::CaptureMap;πuse rustc_middle::mir::*;πuse rustc_middle::thir::*;π
StructsΒ§
- Place
Builder π PlaceBuilderis used to create places during MIR construction. It allows you to βbuild upβ a place by pushing more and more projections onto the end, and then convert the final set into a place using theto_placemethod.
EnumsΒ§
- Place
Base π - The βoutermostβ place that holds this value.
FunctionsΒ§
- convert_
to_ πhir_ projections_ and_ truncate_ for_ capture - Given a list of MIR projections, convert them to list of HIR ProjectionKind.
The projections are truncated to represent a path that might be captured by a
closure/coroutine. This implies the vector returned from this function doesnβt contain
ProjectionElems
Downcast,ConstantIndex,Index, orSubslicebecause those will never be part of a path that is captured by a closure. We stop applying projections once we see the first projection that isnβt captured by a closure. - enable_
precise_ πcapture - Precise capture is enabled if user is using Rust Edition 2021 or higher.
- find_
capture_ πmatching_ projections - Given a closure, returns the index of a capture within the desugared closure struct and the
ty::CapturedPlacewhich is the ancestor of the Place represented using thevar_hir_idandprojection. - is_
ancestor_ πor_ same_ capture - Return true if the
proj_possible_ancestorrepresents an ancestor path toproj_captureorproj_possible_ancestoris same asproj_capture, assuming they both start off of the same root variable. - strip_
prefix π - Returns projections remaining after stripping an initial prefix of HIR projections.
- to_
upvars_ πresolved_ place_ builder - Takes an upvar place and tries to resolve it into a
PlaceBuilderwithPlaceBase::Local