Expand description
MIR-level alias hazard analysis independent of VM state and Z3 terms.
Re-exportsΒ§
use crate::def_ids::type_ids;πuse crate::analysis::dataflow::call_read;πuse crate::analysis::dataflow::call_write;πuse crate::analysis::dataflow::pointer_copy;πuse crate::analysis::dataflow::pointer_flow;πuse crate::analysis::dataflow::pointer_flow::trace_source_arg;πuse crate::util::mir_utils;πuse crate::analysis::dataflow::call_summary::VerifierCallSemantics;πuse crate::analysis::dataflow::call_summary::pointer_semantics;πuse crate::contract::PropertyKind;πuse std::collections::HashMap;πuse std::collections::HashSet;πuse rustc_hir::Safety;πuse rustc_hir::def::DefKind;πuse rustc_hir::def_id::DefId;πuse rustc_middle::mir::BasicBlock;πuse rustc_middle::mir::Body;πuse rustc_middle::mir::Local;πuse rustc_middle::mir::LocalDecls;πuse rustc_middle::mir::Operand;πuse rustc_middle::mir::Place;πuse rustc_middle::mir::ProjectionElem;πuse rustc_middle::mir::Rvalue;πuse rustc_middle::mir::StatementKind;πuse rustc_middle::mir::TerminatorKind;πuse rustc_middle::ty;πuse rustc_middle::ty::AssocKind;πuse rustc_middle::ty::TyCtxt;πuse rustc_middle::ty::TyKind;πuse crate::analysis::alias::FieldOrigin;πuse crate::analysis::alias::resolve_any_field_origin;πuse crate::analysis::alias::resolve_self_field_origin;πuse crate::util::fn_info::is_externally_reachable;πuse crate::util::def_use::PlaceBaseKey;πuse crate::util::def_use::PlaceKey;πuse crate::util::mir_scan::get_fn_safety;πpub(crate) use crate::util::mir_utils::operand_mir_place;πpub(crate) use crate::util::mir_utils::operand_place;πuse crate::util::mir_utils::blocks_reachable_after_call;πuse crate::util::mir_utils::rvalue_any_place_matching;π
StructsΒ§
- Local
Callsite π
EnumsΒ§
- Alias
Producer π - Hazard
Check π - Hazard
Kind π - RawAccess
Kind π
FunctionsΒ§
- alias_
producer π - alias_
proved_ πfor_ param_ local - any_
struct_ πfield_ origin - callsite_
arg_ πorigins - check_
fn_ πagainst_ field - Check whether
item(a struct method or a same-module free function) writes or exposes the raw fieldoriginthrough the borrow carried byself_local. A shared current borrow (&self) is not invalidated by a mutable item borrow (&mut self), and a mutable/mutable pair is likewise fine; any other combination is a violation. Returns the violation description, orNone. - destination_
flows_ πto_ return - escaped_
self_ πfield_ violation - expand_
hazard_ πalias_ locals - expand_
origin_ πaliases - find_
as_ πptr_ receivers - free_
fns_ πfor_ struct - Collect the free functions in the structβs own module that take a
&Struct/&mut Structparameter. Rust privacy is module-scoped, so only those can reach a private raw field. Each entry pairs the function with the parameter locals that carry the struct reference. - hazard_
used_ πafter_ block - hazard_
used_ πafter_ statement - impls_
for_ πstruct - is_
origin_ πa_ reference - is_
ptr_ πadd_ offset_ eq - is_
ptr_ πfrom_ ptr_ add - kill_
strongly_ πupdated_ origins - live_
locals_ πat - Compute the set of locals that are live (between
StorageLiveandStorageDead) at the deref point(call_block, stmt_index), scanning the function in execution order up to that point. Used by the callsite shared-XOR-mutable check to ignore temporaries that have already gone dead (e.g. a method callβs&selfreceiver). - local_
callsites π - local_
hazard_ πviolation - local_
hazard_ πviolation_ with - local_
traces_ πto_ self_ field - Backward-traces
localthrough MIR assignments to check whether its value is derived from(*self_local).field_index. - method_
exposes_ πself_ field - Whether
methodreturns a raw-pointer-bearing value derived from the fieldfield_indexof the struct borrowed viaself_local, i.e. it leaks the raw field to the caller. - method_
writes_ πself_ field - Whether
methodwrites through the raw fieldfield_indexof the struct borrowed viaself_local(_1for a method, any parameter for a free fn). - opaque_
ownership_ πsource_ arg - operand_
local π - ownership_
transfer_ πsource_ arg - ownership_
transfer_ πviolation - param_
index_ πof_ origin - Return the 0-based argument index for
originwhen it is a direct, whole raw-pointer parameter (no field projections, no local-copy tracing). - place_
is_ πraw_ access_ to_ any_ origin - place_
is_ πraw_ access_ to_ live_ origin - place_
is_ πraw_ access_ to_ origin - place_
key_ πis_ prefix_ of - place_
raw_ πaccesses_ self_ field - Whether
placeis a raw-pointer deref whose operand traces back to the fieldfield_indexof the struct borrowed viaself_local. - places_
holding_ πtransferred_ pointer - pointer_
result_ πsource_ arg - pre_
existing_ πview_ on_ origin - private_
fn_ πcallsite_ delegation - public_
raw_ πfield - raw_
access_ πconflicts - raw_
pointer_ πview_ from_ mir - Recognize a returned reference formed by dereferencing a raw pointer derived from one of the calleeβs raw-pointer parameters.
- reconstructed_
owner π - resolve_
mir_ πplace_ tree - Resolve a MIR place through the alias tree: a field-projected place resolves to itself; a whole-local place resolves to its ultimate origin.
- resolve_
param_ πorigin - Resolve
originto a parameter MIR local, tracing through local-copy origins when the base is not itself a parameter. - resolve_
place_ πkey_ tree - Resolve a placeβs local through the alias tree (ignoring the placeβs own field projections), falling back to the MIR place itself when unmapped.
- resolve_
via_ πtree - Resolve
(local, fields)through the alias tree: a place that already names a field path resolves to itself; a whole-local place resolves to its ultimate(root, fields)origin. - reverse_
postorder_ πblocks - rvalue_
copies_ πlive_ origin_ value - rvalue_
mentions_ πany_ local - rvalue_
mentions_ πlocal - rvalue_
mentions_ πorigin - rvalue_
reads_ πany_ origin - rvalue_
reads_ πlike_ view - self_
borrow_ πmutability - The mutability (
Not/Mut) of the borrow carried byself_localβs type (a&T/&mut T), orNoneif it is not a reference.self_localis_1for a method receiver, and any parameter for a free function. - self_
field_ πkey - The
PlaceKeyfor(*self_local).field_index. - self_
field_ πorigin - share_
transfer_ πsource_ arg - splice_
holder_ πfields - statement_
uses_ πany_ local - struct_
ref_ πparam_ locals - Return the parameter locals of
def_idwhose type is a&Struct/&mut Structreference tostruct_def_id. - terminator_
invalidates_ πvec_ owner - terminator_
is_ πbenign_ origin_ use - terminator_
uses_ πany_ local - terminator_
uses_ πlive_ origin - terminator_
uses_ πorigin - terminator_
writes_ πorigin - trace_
owned_ πfield - trace_
returned_ πref