pub struct ChalkDatabase {
    storage: Storage<Self>,
}

Fields§

§storage: Storage<Self>

Implementations§

source§

impl ChalkDatabase

source

pub fn with(program_text: &str, solver_choice: SolverChoice) -> Self

source

pub fn with_program<R>(&self, op: impl FnOnce(&Program) -> R) -> R

source

pub fn parse_and_lower_goal( &self, text: &str ) -> Result<Goal<ChalkIr>, ChalkError>

source

pub fn solve( &self, goal: &UCanonical<InEnvironment<Goal<ChalkIr>>> ) -> Option<Solution<ChalkIr>>

source

pub fn solve_multiple( &self, goal: &UCanonical<InEnvironment<Goal<ChalkIr>>>, f: &mut dyn FnMut(SubstitutionResult<Canonical<ConstrainedSubst<ChalkIr>>>, bool) -> bool ) -> bool

Solves a given goal, producing the solution. This will do only as much work towards goal as it has to (and that works is cached for future attempts). Calls provided function f to iterate over multiple solutions until the function return false.

Trait Implementations§

source§

impl Database for ChalkDatabase

§

fn sweep_all(&self, strategy: SweepStrategy)

Iterates through all query storage and removes any values that have not been used since the last revision was created. The intended use-cycle is that you first execute all of your “main” queries; this will ensure that all query values they consume are marked as used. You then invoke this method to remove other values that were not needed for your main query results.
§

fn salsa_event(&self, event_fn: Event)

This function is invoked at key points in the salsa runtime. It permits the database to be customized and to inject logging or other custom behavior.
§

fn on_propagated_panic(&self) -> !

This function is invoked when a dependent query is being computed by the other thread, and that thread panics.
§

fn salsa_runtime(&self) -> &Runtime

Gives access to the underlying salsa runtime.
§

fn salsa_runtime_mut(&mut self) -> &mut Runtime

Gives access to the underlying salsa runtime.
source§

impl DatabaseOps for ChalkDatabase

source§

fn ops_database(&self) -> &dyn Database

Upcast this type to a dyn Database.
source§

fn ops_salsa_runtime(&self) -> &Runtime

Gives access to the underlying salsa runtime.
source§

fn ops_salsa_runtime_mut(&mut self) -> &mut Runtime

Gives access to the underlying salsa runtime.
source§

fn fmt_index(&self, input: DatabaseKeyIndex, fmt: &mut Formatter<'_>) -> Result

Formats a database key index in a human readable fashion.
source§

fn maybe_changed_since( &self, input: DatabaseKeyIndex, revision: Revision ) -> bool

True if the computed value for input may have changed since revision.
source§

fn for_each_query(&self, op: &mut dyn FnMut(&dyn QueryStorageMassOps))

Executes the callback for each kind of query.
source§

impl DatabaseStorageTypes for ChalkDatabase

§

type DatabaseStorage = __SalsaDatabaseStorage

Defines the “storage type”, where all the query data is kept. This type is defined by the database_storage macro.
source§

impl Debug for ChalkDatabase

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ChalkDatabase

source§

fn default() -> ChalkDatabase

Returns the “default value” for a type. Read more
source§

impl HasQueryGroup<Lowering> for ChalkDatabase

source§

fn group_storage(&self) -> &<Lowering as QueryGroup>::GroupStorage

Access the group storage struct from the database.
source§

impl RustIrDatabase<ChalkIr> for ChalkDatabase

source§

fn custom_clauses(&self) -> Vec<ProgramClause<ChalkIr>>

Returns any “custom program clauses” that do not derive from Rust IR. Used only in testing the underlying solver.
source§

fn associated_ty_data( &self, ty: AssocTypeId<ChalkIr> ) -> Arc<AssociatedTyDatum<ChalkIr>>

Returns the datum for the associated type with the given id.
source§

fn trait_datum(&self, id: TraitId<ChalkIr>) -> Arc<TraitDatum<ChalkIr>>

Returns the datum for the definition with the given id.
source§

fn impl_datum(&self, id: ImplId<ChalkIr>) -> Arc<ImplDatum<ChalkIr>>

Returns the datum for the impl with the given id.
source§

fn associated_ty_value( &self, id: AssociatedTyValueId<ChalkIr> ) -> Arc<AssociatedTyValue<ChalkIr>>

Returns the AssociatedTyValue with the given id.
source§

fn opaque_ty_data(&self, id: OpaqueTyId<ChalkIr>) -> Arc<OpaqueTyDatum<ChalkIr>>

Returns the OpaqueTyDatum with the given id.
source§

fn hidden_opaque_type(&self, id: OpaqueTyId<ChalkIr>) -> Ty<ChalkIr>

Returns the “hidden type” corresponding with the opaque type.
source§

fn adt_datum(&self, id: AdtId<ChalkIr>) -> Arc<AdtDatum<ChalkIr>>

Returns the datum for the ADT with the given id.
source§

fn coroutine_datum( &self, id: CoroutineId<ChalkIr> ) -> Arc<CoroutineDatum<ChalkIr>>

Returns the coroutine datum for the coroutine with the given id.
source§

fn coroutine_witness_datum( &self, id: CoroutineId<ChalkIr> ) -> Arc<CoroutineWitnessDatum<ChalkIr>>

Returns the coroutine witness datum for the coroutine with the given id.
source§

fn adt_repr(&self, id: AdtId<ChalkIr>) -> Arc<AdtRepr<ChalkIr>>

Returns the representation for the ADT definition with the given id.
source§

fn adt_size_align(&self, id: AdtId<ChalkIr>) -> Arc<AdtSizeAlign>

Returns the siza and alignment of the ADT definition with the given id.
source§

fn fn_def_datum(&self, id: FnDefId<ChalkIr>) -> Arc<FnDefDatum<ChalkIr>>

Returns the datum for the fn definition with the given id.
source§

fn impls_for_trait( &self, trait_id: TraitId<ChalkIr>, generic_args: &[GenericArg<ChalkIr>], binders: &CanonicalVarKinds<ChalkIr> ) -> Vec<ImplId<ChalkIr>>

Returns a list of potentially relevant impls for a given trait-id; we also supply the type parameters that we are trying to match (if known: these parameters may contain inference variables, for example). The implementor is permitted to return any superset of the applicable impls; chalk will narrow down the list to only those that truly apply. The parameters are provided as a “hint” to help the implementor do less work, but can be completely ignored if desired. Read more
source§

fn local_impls_to_coherence_check( &self, trait_id: TraitId<ChalkIr> ) -> Vec<ImplId<ChalkIr>>

Returns the impls that require coherence checking. This is not the full set of impls that exist: Read more
source§

fn impl_provided_for( &self, auto_trait_id: TraitId<ChalkIr>, ty: &TyKind<ChalkIr> ) -> bool

Returns true if there is an explicit impl of the auto trait auto_trait_id for the type ty. This is part of the auto trait handling – if there is no explicit impl given by the user for ty, then we provide default impls (otherwise, we rely on the impls the user gave).
source§

fn well_known_trait_id( &self, well_known_trait: WellKnownTrait ) -> Option<TraitId<ChalkIr>>

Returns id of a trait lang item, if found
source§

fn program_clauses_for_env( &self, environment: &Environment<ChalkIr> ) -> ProgramClauses<ChalkIr>

Calculates program clauses from an env. This is intended to call the program_clauses_for_env function and then possibly cache the clauses.
source§

fn interner(&self) -> ChalkIr

source§

fn is_object_safe(&self, trait_id: TraitId<ChalkIr>) -> bool

Check if a trait is object safe
source§

fn closure_inputs_and_output( &self, closure_id: ClosureId<ChalkIr>, substs: &Substitution<ChalkIr> ) -> Binders<FnDefInputsAndOutputDatum<ChalkIr>>

Gets the inputs and output for a given closure id and substitution. We pass both the ClosureId and it’s Substituion to give implementors the freedom to store associated data in the substitution (like rustc) or separately (like chalk-integration).
source§

fn closure_kind( &self, closure_id: ClosureId<ChalkIr>, substs: &Substitution<ChalkIr> ) -> ClosureKind

Gets the ClosureKind for a given closure and substitution.
source§

fn closure_upvars( &self, closure_id: ClosureId<ChalkIr>, substs: &Substitution<ChalkIr> ) -> Binders<Ty<ChalkIr>>

Gets the upvars as a Ty for a given closure id and substitution. There are no restrictions on the type of upvars.
source§

fn closure_fn_substitution( &self, closure_id: ClosureId<ChalkIr>, substs: &Substitution<ChalkIr> ) -> Substitution<ChalkIr>

Gets the substitution for the closure when used as a function. For example, for the following (not-quite-)rust code: Read more
source§

fn unification_database(&self) -> &dyn UnificationDatabase<ChalkIr>

source§

fn trait_name(&self, trait_id: TraitId<ChalkIr>) -> String

Retrieves a trait’s original name. No uniqueness guarantees, but must a valid Rust identifier.
source§

fn adt_name(&self, struct_id: AdtId<ChalkIr>) -> String

Retrieves a struct’s original name. No uniqueness guarantees, but must a valid Rust identifier.
source§

fn assoc_type_name(&self, assoc_ty_id: AssocTypeId<ChalkIr>) -> String

Retrieves the name of an associated type. No uniqueness guarantees, but must a valid Rust identifier.
source§

fn opaque_type_name(&self, opaque_ty_id: OpaqueTyId<ChalkIr>) -> String

Retrieves the name of an opaque type. No uniqueness guarantees, but must a valid Rust identifier.
source§

fn fn_def_name(&self, fn_def_id: FnDefId<ChalkIr>) -> String

Retrieves the name of a function definition. No uniqueness guarantees, but must a valid Rust identifier.
source§

fn discriminant_type(&self, ty: Ty<ChalkIr>) -> Ty<ChalkIr>

source§

impl UnificationDatabase<ChalkIr> for ChalkDatabase

source§

fn fn_def_variance(&self, fn_def_id: FnDefId<ChalkIr>) -> Variances<ChalkIr>

Gets the variances for the substitution of a fn def
source§

fn adt_variance(&self, adt_id: AdtId<ChalkIr>) -> Variances<ChalkIr>

Gets the variances for the substitution of a adt

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Cast for T

source§

fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<DB> LoweringDatabase for DB
where DB: RustIrDatabase<ChalkIr> + Database + Upcast<dyn RustIrDatabase<ChalkIr>> + HasQueryGroup<Lowering>,

source§

fn program_text(&self) -> Arc<String>

source§

fn set_program_text(&mut self, value__: Arc<String>)

Set the value of the program_text input. Read more
source§

fn set_program_text_with_durability( &mut self, value__: Arc<String>, durability__: Durability )

Set the value of the program_text input and promise that its value will never change again. Read more
source§

fn solver_choice(&self) -> SolverChoice

source§

fn set_solver_choice(&mut self, value__: SolverChoice)

Set the value of the solver_choice input. Read more
source§

fn set_solver_choice_with_durability( &mut self, value__: SolverChoice, durability__: Durability )

Set the value of the solver_choice input and promise that its value will never change again. Read more
source§

fn program_ir(&self) -> Result<Arc<Program>, ChalkError>

source§

fn coherence( &self ) -> Result<BTreeMap<TraitId<ChalkIr>, Arc<SpecializationPriorities<ChalkIr>>>, ChalkError>

Performs coherence check and computes which impls specialize one another (the “specialization priorities”).
source§

fn orphan_check(&self) -> Result<(), ChalkError>

source§

fn checked_program(&self) -> Result<Arc<Program>, ChalkError>

The lowered IR, with coherence, orphan, and WF checks performed.
source§

fn environment(&self) -> Result<Arc<ProgramEnvironment>, ChalkError>

The program as logic.
source§

fn solver(&self) -> ArcEq<Mutex<Box<dyn Solver<ChalkIr>>>>

Creates the solver we can use to solve goals. This solver stores intermediate, cached state, which is why it is behind a mutex. Moreover, if the set of program clauses change, that cached state becomes invalid, so the query is marked as volatile, thus ensuring that the solver is recreated in every revision (i.e., each time source program changes).
source§

impl<DB, I> Split<I> for DB
where DB: RustIrDatabase<I> + ?Sized, I: Interner,

source§

fn split_projection<'p>( &self, projection: &'p ProjectionTy<I> ) -> (Arc<AssociatedTyDatum<I>>, &'p [GenericArg<I>], &'p [GenericArg<I>])

Given a projection of an associated type, split the type parameters into those that come from the trait and those that come from the associated type itself. So e.g. if you have (Iterator::Item)<F>, this would return ([F], []), since Iterator::Item is not generic and hence doesn’t have any type parameters itself.
source§

fn trait_parameters_from_projection<'p>( &self, projection: &'p ProjectionTy<I> ) -> &'p [GenericArg<I>]

Given a projection <P0 as Trait<P1..Pn>>::Item<Pn..Pm>, returns the trait parameters [P0..Pn] (see split_projection).
source§

fn trait_ref_from_projection(&self, projection: &ProjectionTy<I>) -> TraitRef<I>

Given a projection <P0 as Trait<P1..Pn>>::Item<Pn..Pm>, returns the trait parameters [P0..Pn] (see split_projection).
source§

fn split_associated_ty_value_parameters<P, 'p>( &self, parameters: &'p [P], associated_ty_value: &AssociatedTyValue<I> ) -> (&'p [P], &'p [P])

Given the full set of parameters (or binders) for an associated type value (which appears in an impl), splits them into the substitutions for the impl and those for the associated type. Read more
source§

fn impl_parameters_and_projection_from_associated_ty_value<'p>( &self, parameters: &'p [GenericArg<I>], associated_ty_value: &AssociatedTyValue<I> ) -> (&'p [GenericArg<I>], ProjectionTy<I>)

Given the full set of parameters for an associated type value (which appears in an impl), returns the trait reference and projection that are being satisfied by that value. Read more
source§

fn split_associated_ty_parameters<P, 'p>( &self, parameters: &'p [P], associated_ty_datum: &AssociatedTyDatum<I> ) -> (&'p [P], &'p [P])

Given the full set of parameters (or binders) for an associated type datum (the one appearing in a trait), splits them into the parameters for the trait and those for the associated type. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U> Upcast<U> for T
where U: UpcastFrom<T> + ?Sized, T: ?Sized,

source§

fn upcast(&self) -> &U

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more