Skip to main content

Module rty

Module rty 

Source
Expand description

Defines how flux represents refinement types internally. Definitions in this module are used during refinement type checking. A couple of important differences between definitions in this module and in crate::fhir are:

  • Types in this module use debruijn indices to represent local binders.
  • Data structures are interned so they can be cheaply cloned.

Re-exportsΒ§

use std::borrow::Cow; πŸ”’
use std::cmp::Ordering; πŸ”’
use std::fmt; πŸ”’
use std::hash::Hash; πŸ”’
use std::hash::Hash; πŸ”’
use std::sync::LazyLock; πŸ”’
pub use binder::Binder;
pub use binder::BoundReftKind;
pub use binder::BoundVariableKind;
pub use binder::BoundVariableKinds;
pub use binder::EarlyBinder;
use bitflags::bitflags; πŸ”’
pub use expr::AggregateKind;
pub use expr::AliasReft;
pub use expr::BinOp;
pub use expr::BoundReft;
pub use expr::Constant;
pub use expr::Ctor;
pub use expr::ESpan;
pub use expr::EVid;
pub use expr::EarlyReftParam;
pub use expr::Expr;
pub use expr::ExprKind;
pub use expr::FieldProj;
pub use expr::HoleKind;
pub use expr::InternalFuncKind;
pub use expr::KVar;
pub use expr::KVid;
pub use expr::Lambda;
pub use expr::Loc;
pub use expr::Name;
pub use expr::NameProvenance;
pub use expr::Path;
pub use expr::PrettyMap;
pub use expr::PrettyVar;
pub use expr::QuantDom;
pub use expr::RawPtrField;
pub use expr::Real;
pub use expr::SpecFuncKind;
pub use expr::UnOp;
pub use expr::Var;
pub use expr::WKVar;
pub use expr::WKVid;
use flux_arc_interner::Interned; πŸ”’
use flux_common::bug; πŸ”’
use flux_common::bug; πŸ”’
use flux_common::tracked_span_assert_eq; πŸ”’
use flux_common::tracked_span_bug; πŸ”’
use flux_config::OverflowMode; πŸ”’
use flux_macros::TypeFoldable; πŸ”’
use flux_macros::TypeVisitable; πŸ”’
use flux_rustc_bridge::ToRustc; πŸ”’
use flux_rustc_bridge::mir::Place; πŸ”’
use flux_rustc_bridge::mir::RawPtrKind; πŸ”’
use flux_rustc_bridge::ty; πŸ”’
use flux_rustc_bridge::ty::GenericArgsExt as _; πŸ”’
use flux_rustc_bridge::ty::VariantDef; πŸ”’
use itertools::Itertools; πŸ”’
use rustc_abi; πŸ”’
use rustc_abi; πŸ”’
use rustc_attr_ir::LangItem; πŸ”’
use rustc_data_structures::fx::FxIndexMap; πŸ”’
use rustc_data_structures::snapshot_map::SnapshotMap; πŸ”’
use rustc_data_structures::unord::UnordMap; πŸ”’
use rustc_hir::Safety; πŸ”’
use rustc_hir::def_id::DefId; πŸ”’
use rustc_index::IndexSlice; πŸ”’
use rustc_index::IndexVec; πŸ”’
use rustc_index::newtype_index; πŸ”’
use rustc_macros::Decodable; πŸ”’
use rustc_macros::Encodable; πŸ”’
use rustc_macros::TyDecodable; πŸ”’
use rustc_macros::TyEncodable; πŸ”’
use rustc_macros::extension; πŸ”’
use rustc_middle::query::IntoQueryKey; πŸ”’
use rustc_middle::ty::TyCtxt; πŸ”’
use rustc_middle::ty::fast_reject::SimplifiedType; πŸ”’
use rustc_span::DUMMY_SP; πŸ”’
use rustc_span::Span; πŸ”’
use rustc_span::Symbol; πŸ”’
use rustc_span::sym; πŸ”’
use rustc_span::symbol::kw; πŸ”’
use rustc_type_ir::Upcast as _; πŸ”’
pub use spec_func::SpecFunc;
pub use spec_func::SpecFuncs;
pub use spec_func::deps;
use self::fold::TypeFoldable; πŸ”’
pub use crate::fhir::InferMode;
use crate::LocalDefId; πŸ”’
use crate::def_id::FluxDefId; πŸ”’
use crate::def_id::FluxLocalDefId; πŸ”’
use crate::fhir; πŸ”’
use crate::fhir::FhirId; πŸ”’
use crate::fhir::FluxOwnerId; πŸ”’
use crate::global_env::GlobalEnv; πŸ”’
use crate::pretty::Pretty; πŸ”’
use crate::pretty::PrettyCx; πŸ”’
use crate::queries::QueryErr; πŸ”’
use crate::queries::QueryResult; πŸ”’
use crate::rty::subst::SortSubst; πŸ”’
pub use crate::_Int as Int;
pub use crate::_Uint as Uint;
pub use crate::_Bool as Bool;
pub use crate::_Char as Char;
pub use crate::_Ref as Ref;
pub use flux_rustc_bridge::ty::Region::*;

ModulesΒ§

binder πŸ”’
canonicalize
A canonical type is a type where all existentials and constraint predicates are hoisted to the top level. For example, the canonical version of βˆƒa. {βˆƒb. i32[a + b] | b > 0} is βˆƒa,b. {i32[a + b] | b > 0}.
expr πŸ”’
fold
This modules follows the implementation of folding in rustc. For more information read the documentation in rustc_type_ir::fold.
pretty πŸ”’
reduce
refining
Refining is the process of generating a refined version of a rust type.
region_matching
spec_func πŸ”’
subst

StructsΒ§

AdtDef
AdtDefData
AdtSortDef
The definition of the data sort automatically generated for a struct or enum.
AdtSortDefData πŸ”’
AdtSortVariant
AliasTerm
Mirrors flux_rustc_bridge::ty::AliasTerm.
AliasTy
AssocRefinements
AssocReft
Axiom
An Axiom is a (global) fact, typically about uninterpreted functions, that is assumed to hold for all values of the variables bound in body.
AxiomBody
BoundRegion
BvSizeVid
A bit vector size vvariable id
Clause
Const
CoroutineObligPredicate
ExistentialProjection
ExistentialTraitRef
FnOutput
FnSig
FnTraitPredicate
FuncSort
GenericParamDef
GenericPredicates
Generics
Invariant
LateParamRegion
Mirrors [rustc_middle::ty::LateParamRegion].
LocalTableInContext
LocalTableInContextMut
OutlivesPredicate
ParamSort
ParamSort is used for polymorphic sorts (Set, Map, etc.) and bit-vector size parameters. They should occur β€œbound” under a PolyFuncSort or an AdtSortDef. We assume there’s a single binder and a ParamSort represents a variable as an index into the list of variables bound by that binder, i.e., the representation doesnt’t support higher-ranked sorts.
PolyFuncSort
A polymorphic function sort parametric over sorts or bit-vector sizes.
PrimOpProp
A PrimOpProp is a single property for a primitive operation which can be conjoined to get the definition of the PrimRel for that primitive operation.
PrimRel
All the properties of a primitive operation. The properties that apply to a function are conjoined to get the definition of the primitive relation for that operation; see crate::global_env::GlobalEnv::prim_rel_for.
ProjectionPredicate
Qualifier
RefineParam
RefinementGenerics
SortCstr
A sort constraint is a set of operations a sort must support.
SortVid
A sort vvariable id
SubsetTy
A subset type is a simplified version of a type that has the form {b[e] | p} where b is a BaseTy, e a refinement index, and p a predicate.
TraitPredicate
TraitRef
Ty
UncoveredAxiomVar
The variable (by its position in the axiom’s binder) that does not occur in any pattern of an ill-formed axiom. See Axiom::new.
VariantSig
WfckResults
AdtFlags
BoundVar
ConstVid
A const variable ID.
DebruijnIndex
A De Bruijn index is a standard means of representing regions (and perhaps later types) in a higher-ranked setting. In particular, imagine a type like this:
EarlyParamRegion
ParamConst
ParamTy
RegionVid
A region variable ID.
ScalarInt
The raw bytes of a simple value.
TyVid
A type variable ID.
VariantIdx
The source-order index of a variant in a type.

EnumsΒ§

AliasKind
AliasTermKind
BaseTy
BoundRegionKind
BvSize
The size of a bit-vector
CastKind
ClauseKind
Coercion
ConstKind
ConstantInfo
Ensures
ExistentialPredicate
GenericArg
GenericParamDefKind
HintKind
Determines which functions a hint to the solver (a qualifier, an axiom or a primop property) is used for
Opaqueness
Option-like enum to explicitly mark that we don’t have information about an ADT because it was annotated with #[flux::opaque]. Note that only structs can be marked as opaque.
PtrKind
RecordCtor
Region
Sort
SortArg
An argument for a generic parameter in a Sort which can be either a generic sort or a generic bit-vector size.
SortCtor
SortParamKind
See PolyFuncSort
SortVarVal
Unification value for sort variables used during sort checking.
TyKind
TyOrBase
TyOrCtor
ClosureKind
Represents the various closure traits in the language. This will determine the type of the environment (self, in the desugaring) argument that the closure expects.
FloatTy
IntTy
LateParamRegionKind
When liberating bound regions, we map their [ty::BoundRegionKind] to this as we need to track the index of anonymous regions. We otherwise end up liberating multiple bound regions to the same late-bound region.
Mutability
UintTy

ConstantsΒ§

SELF_PARAM_TY
FIRST_VARIANT
Equivalent to VariantIdx(0).
INNERMOST

StaticsΒ§

INT_TYS
UINT_TYS

TraitsΒ§

GenericArgsExt
RefineArgsExt

FunctionsΒ§

auto_strong
The auto_strong function transforms function signatures by automatically converting mutable reference parameters into strong references with associated ensures clauses. This transformation is applied only when the function signature does not already contain region variables in its return type.
can_auto_strong πŸ”’
char_invariants πŸ”’
int_invariants πŸ”’
raw_ptr_invariants πŸ”’
slice_invariants πŸ”’
All slices have 0 <= len <= usize::MAX, with the upper bound subject to overflow checking.
to_closure_sig
uint_invariants πŸ”’

Type AliasesΒ§

Clauses
GenericArgs
ItemLocalMap
List
PolyExistentialPredicate
PolyExistentialTraitRef
PolyFnSig
PolyProjectionPredicate
PolyTraitPredicate
PolyTraitRef
PolyVariant
PolyVariants
RefineArgs
RegionOutlivesPredicate
SubsetTyCtor
A type constructor meant to be used as generic a argument of kind base. This is just an alias to Binder<SubsetTy>, but we expect the binder to have a single bound variable of the sort of the underlying base type.
TyCtor
TypeOutlivesPredicate