Skip to main content

InferCtxtExt

Trait InferCtxtExt 

Source
pub trait InferCtxtExt<'tcx> {
    // Required method
    fn infer_opaque_definition_from_instantiation(
        &self,
        opaque_type_key: OpaqueTypeKey<'tcx>,
        instantiated_ty: ProvisionalHiddenType<'tcx>,
    ) -> Result<DefinitionSiteHiddenType<'tcx>, NonDefiningUseReason<'tcx>>;
}

Required Methods§

Source

fn infer_opaque_definition_from_instantiation( &self, opaque_type_key: OpaqueTypeKey<'tcx>, instantiated_ty: ProvisionalHiddenType<'tcx>, ) -> Result<DefinitionSiteHiddenType<'tcx>, NonDefiningUseReason<'tcx>>

Given the fully resolved, instantiated type for an opaque type, i.e., the value of an inference variable like C1 or C2 (*), computes the “definition type” for an opaque type definition – that is, the inferred value of Foo1<'x> or Foo2<'x> that we would conceptually use in its definition:

type Foo1<'x> = impl Bar<'x> = AAA;  // <-- this type AAA
type Foo2<'x> = impl Bar<'x> = BBB;  // <-- or this type BBB
fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }

Note that these values are defined in terms of a distinct set of generic parameters ('x instead of 'a) from C1 or C2. The main purpose of this function is to do that translation.

(*) C1 and C2 were introduced in the comments on register_member_constraints. Read that comment for more context.

Implementations on Foreign Types§

Source§

impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx>

Source§

fn infer_opaque_definition_from_instantiation( &self, opaque_type_key: OpaqueTypeKey<'tcx>, instantiated_ty: ProvisionalHiddenType<'tcx>, ) -> Result<DefinitionSiteHiddenType<'tcx>, NonDefiningUseReason<'tcx>>

Given the fully resolved, instantiated type for an opaque type, i.e., the value of an inference variable like C1 or C2 (*), computes the “definition type” for an opaque type definition – that is, the inferred value of Foo1<'x> or Foo2<'x> that we would conceptually use in its definition:

type Foo1<'x> = impl Bar<'x> = AAA;  // <-- this type AAA
type Foo2<'x> = impl Bar<'x> = BBB;  // <-- or this type BBB
fn foo<'a, 'b>(..) -> (Foo1<'a>, Foo2<'b>) { .. }

Note that these values are defined in terms of a distinct set of generic parameters ('x instead of 'a) from C1 or C2. The main purpose of this function is to do that translation.

(*) C1 and C2 were introduced in the comments on register_member_constraints. Read that comment for more context.

Implementors§