Expand description
This crate implemens MIR typeck and MIR borrowck.
Re-exportsΒ§
pub(crate) use borrow_set::LocalsStateAtExit;πpub(crate) use root_cx::BorrowCheckRootCtxt;πpub(crate) use crate::borrow_set::BorrowData;πpub(crate) use crate::borrow_set::BorrowSet;πpub(crate) use crate::consumers::BodyWithBorrowckFacts;πpub(crate) use crate::consumers::RustcFacts;πpub(crate) use crate::dataflow::BorrowIndex;πpub(crate) use crate::dataflow::Borrowck;πpub(crate) use crate::dataflow::BorrowckDomain;πpub(crate) use crate::dataflow::Borrows;πpub(crate) use crate::diagnostics::AccessKind;πpub(crate) use crate::diagnostics::BorrowckDiagnosticsBuffer;πpub(crate) use crate::diagnostics::IllegalMoveOriginKind;πpub(crate) use crate::diagnostics::MoveError;πpub(crate) use crate::diagnostics::RegionName;πpub(crate) use crate::implied_bounds::mir_borrowck_implied_outlives_bounds;πpub(crate) use crate::place_ext::PlaceExt;πpub(crate) use crate::places_conflict::PlaceConflictBias;πpub(crate) use crate::places_conflict::places_conflict;πpub(crate) use crate::polonius::PoloniusContext;πpub(crate) use crate::polonius::legacy::PoloniusFacts;πpub(crate) use crate::polonius::legacy::PoloniusFactsExt;πpub(crate) use crate::polonius::legacy::PoloniusLocationTable;πpub(crate) use crate::polonius::legacy::PoloniusOutput;πpub(crate) use crate::prefixes::PrefixSet;πpub(crate) use crate::region_infer::RegionInferenceContext;πpub(crate) use crate::region_infer::opaque_types::DeferredOpaqueTypeError;πpub(crate) use crate::renumber::RegionCtxt;πpub(crate) use crate::session_diagnostics::VarNeedNotMut;πpub(crate) use crate::type_check::free_region_relations::UniversalRegionRelations;πpub(crate) use crate::type_check::Locations;πpub(crate) use crate::type_check::MirTypeckRegionConstraints;πpub(crate) use crate::type_check::MirTypeckResults;πpub(crate) use self::AccessDepth::Deep;πpub(crate) use self::AccessDepth::Shallow;πpub(crate) use self::ReadOrWrite::Activation;πpub(crate) use self::ReadOrWrite::Read;πpub(crate) use self::ReadOrWrite::Reservation;πpub(crate) use self::ReadOrWrite::Write;πpub(crate) use std::borrow::Cow;πpub(crate) use OnceCell;πpub(crate) use RefCell;πpub(crate) use std::marker::PhantomData;πpub(crate) use ControlFlow;πpub(crate) use Deref;πpub(crate) use std::rc::Rc;πpub(crate) use polonius_engine::AllFacts;πpub(crate) use rustc_abi::FieldIdx;πpub(crate) use rustc_data_structures::frozen::Frozen;πpub(crate) use FxIndexMap;πpub(crate) use FxIndexSet;πpub(crate) use rustc_data_structures::graph::dominators::Dominators;πpub(crate) use rustc_hir as hir;πpub(crate) use rustc_hir::CRATE_HIR_ID;πpub(crate) use rustc_hir::def_id::LocalDefId;πpub(crate) use rustc_index::bit_set::MixedBitSet;πpub(crate) use IndexSlice;πpub(crate) use IndexVec;πpub(crate) use rustc_infer::infer::outlives::env::RegionBoundPairs;πpub(crate) use InferCtxt;πpub(crate) use NllRegionVariableOrigin;πpub(crate) use RegionVariableOrigin;πpub(crate) use TyCtxtInferExt;πpub(crate) use TAIL_EXPR_DROP_ORDER;πpub(crate) use UNUSED_MUT;πpub(crate) use rustc_middle::query::Providers;πpub(crate) use ty;πpub(crate) use ParamEnv;πpub(crate) use RegionVid;πpub(crate) use Ty;πpub(crate) use TyCtxt;πpub(crate) use TypeFoldable;πpub(crate) use TypeVisitable;πpub(crate) use TypingMode;πpub(crate) use fold_regions;πpub(crate) use EverInitializedPlaces;πpub(crate) use MaybeUninitializedPlaces;πpub(crate) use InitIndex;πpub(crate) use InitLocation;πpub(crate) use LookupResult;πpub(crate) use MoveData;πpub(crate) use MovePathIndex;πpub(crate) use rustc_mir_dataflow::points::DenseLocationMap;πpub(crate) use Analysis;πpub(crate) use EntryStates;πpub(crate) use Results;πpub(crate) use ResultsVisitor;πpub(crate) use visit_results;πpub(crate) use ErrorGuaranteed;πpub(crate) use Span;πpub(crate) use Symbol;πpub(crate) use bug;πpub(crate) use span_bug;πpub(crate) use QueryTypeOp;πpub(crate) use TypeOp;πpub(crate) use TypeOpOutput;πpub(crate) use smallvec::SmallVec;πpub(crate) use debug;πpub(crate) use instrument;πpub(crate) use instrument;πpub(crate) use rustc_middle::mir::*;π
ModulesΒ§
- borrow_
set π - borrowck_
errors π - constraints π
- consumers
- A public API provided for the Rust compiler consumers. This file provides API for compiler consumers.
- dataflow π
- def_use π
- diagnostics π
- Borrow checker diagnostics.
- handle_
placeholders π - Logic for lowering higher-kinded outlives constraints (with placeholders and universes) and turn them into regular outlives constraints.
- implied_
bounds π - nll π
- The entry point of the NLL borrow checker.
- path_
utils π - place_
ext π - places_
conflict π - The borrowck rules for proving disjointness are applied from the βrootβ of the
borrow forwards, iterating over βsimilarβ projections in lockstep until
we can prove overlap one way or another. Essentially, we treat
Overlapas a monoid and report a conflict if the product ends up not beingDisjoint. - polonius π
- Polonius analysis and support code:
- prefixes π
- From the NLL RFC:
βShallow prefixes are found by stripping away fields, but stop at
any dereference. So: writing a path like
ais illegal ifa.bis borrowed. But: writingais legal if*ais borrowed, whether or notais a shared or mutable reference. [β¦] β - region_
infer π - renumber π
- root_cx π
- session_
diagnostics π - type_
check π - This pass type-checks the MIR to ensure it is not broken.
- universal_
regions π - Code to extract the universally quantified regions declared on a function. For example:
- used_
muts π
StructsΒ§
- Borrowck
Infer πCtxt - Closure
Outlives Requirement - Indicates an outlives-constraint between a type or between two free regions declared on the closure.
- Closure
Outlives Subject Ty - Represents a
ty::Tyfor use inClosureOutlivesSubject. - Closure
Region Requirements - After we borrow check a closure, we are left with various requirements that we have inferred between the free regions that appear in the closureβs signature or on its field types. These requirements are then verified and proved by the closureβs creating function. This struct encodes those requirements.
- Collect
Region πConstraints Result - MirBorrowck
Ctxt π - Propagated
Borrow πCheck Results - Data propagated to the typeck parent by nested items. This should always be empty for the typeck root.
- Root
Place π - TyCtxt
Consts π - Associate some local constants with the
'tcxlifetime
EnumsΒ§
- Access
Depth π - Artificial
Field π - Closure
Outlives Subject - The subject of a
ClosureOutlivesRequirementβ that is, the thing that must outlive some region. - Initialization
Requiring πAction - Local
Mutation πIsAllowed - When checking permissions for a place access, this flag is used to indicate that an immutable local place can be mutated.
- Overlap π
- The degree of overlap between 2 places for borrow-checking.
- Read
Kind π - Kind of read access to a value (For informational purposes only)
- Read
OrWrite π - Kind of access to a value: read or write (For informational purposes only)
- Write
Kind π - Kind of write access to a value (For informational purposes only)
FunctionsΒ§
- borrow_
of_ πlocal_ data - Determines if a given borrow is borrowing local data This is called for all Yield expressions on movable coroutines
- borrowck_
check_ πregion_ constraints - Using the region constraints computed by borrowck_collect_region_constraints and the additional constraints from BorrowCheckRootCtxt::handle_opaque_type_uses, compute the region graph and actually check for any borrowck errors.
- borrowck_
collect_ πregion_ constraints - Start borrow checking by collecting the region constraints for the current body. This initializes the relevant data structures and then type checks the MIR body.
- each_
borrow_ πinvolving_ path - Encapsulates the idea of iterating over every borrow that involves a particular path
- get_
flow_ πresults - is_
active π - is_
upvar_ πfield_ projection - If
placeis a field projection, and the field is being projected from a closure type, then returns the index of the field being projected. Note that this closure will always beselfin the current MIR, because that is the only time we directly access the fields of a closure type. - mir_
borrowck π - Provider for
query mir_borrowck. Unliketypeck, this must only be called for typeck roots which similar totypeckwill then borrowck all nested bodies as well. - provide