Struct rustc_typeck::middle::traits::FulfillmentContext [−] [src]

pub struct FulfillmentContext<'tcx> {
    // some fields omitted
}
Unstable

The fulfillment context is used to drive trait resolution. It consists of a list of obligations that must be (eventually) satisfied. The job is to track which are satisfied, which yielded errors, and which are still pending. At any point, users can call select_where_possible, and the fulfilment context will try to do selection, retaining only those obligations that remain ambiguous. This may be helpful in pushing type inference along. Once all type inference constraints have been generated, the method select_all_or_error can be used to report any remaining ambiguous cases as errors.

Methods

impl<'tcx> FulfillmentContext<'tcx>

fn new() -> FulfillmentContext<'tcx>

Unstable

fn normalize_projection_type(&mut self, infcx: &InferCtxt<'a, 'tcx>, typer: &ClosureTyper<'tcx>, projection_ty: ProjectionTy<'tcx>, cause: ObligationCause<'tcx>) -> &'tcx TyS<'tcx>

Unstable

"Normalize" a projection type <SomeType as SomeTrait>::X by creating a fresh type variable $0 as well as a projection predicate <SomeType as SomeTrait>::X == $0. When the inference engine runs, it will attempt to find an impl of SomeTrait or a where clause that lets us unify $0 with something concrete. If this fails, we'll unify $0 with projection_ty again.

fn register_builtin_bound(&mut self, infcx: &InferCtxt<'a, 'tcx>, ty: &'tcx TyS<'tcx>, builtin_bound: BuiltinBound, cause: ObligationCause<'tcx>)

Unstable

fn register_region_obligation(&mut self, infcx: &InferCtxt<'a, 'tcx>, t_a: &'tcx TyS<'tcx>, r_b: Region, cause: ObligationCause<'tcx>)

Unstable

fn register_predicate_obligation(&mut self, infcx: &InferCtxt<'a, 'tcx>, obligation: Obligation<'tcx, Predicate<'tcx>>)

Unstable

fn region_obligations(&self, body_id: u32) -> &[RegionObligation<'tcx>]

Unstable

fn select_all_or_error(&mut self, infcx: &InferCtxt<'a, 'tcx>, typer: &ClosureTyper<'tcx>) -> Result<(), Vec<FulfillmentError<'tcx>>>

Unstable

fn select_new_obligations(&mut self, infcx: &InferCtxt<'a, 'tcx>, typer: &ClosureTyper<'tcx>) -> Result<(), Vec<FulfillmentError<'tcx>>>

Unstable

Attempts to select obligations that were registered since the call to a selection routine. This is used by the type checker to eagerly attempt to resolve obligations in hopes of gaining type information. It'd be equally valid to use select_where_possible but it results in O(n^2) performance (#18208).

fn select_where_possible(&mut self, infcx: &InferCtxt<'a, 'tcx>, typer: &ClosureTyper<'tcx>) -> Result<(), Vec<FulfillmentError<'tcx>>>

Unstable

fn pending_obligations(&self) -> &[Obligation<'tcx, Predicate<'tcx>>]

Unstable