Skip to main content

Module fn_subtyping

Module fn_subtyping 

Source
Expand description

Subtyping between function signatures.

This is used to check, e.g., that the signature of a trait method’s implementation is a subtype of the trait method’s signature, that a closure satisfies an Fn trait obligation, or that a fn pointer can be used where another fn pointer is expected.

Structs§

SkipConstr 🔒

Enums§

SubFn
SubFn lets us reuse most of the same code for check_fn_subtyping for both the case where we have an early-bound function signature (e.g., for a trait method???) and versions without, e.g. a plain closure against its FnTraitPredicate obligation.

Functions§

check_fn_subtyping
The function check_fn_subtyping does a function subtyping check between the sub-type (T_f) corresponding to the type of def_id @ args and the super-type (T_g) corresponding to the oblig_sig. This subtyping is handled as akin to the code
infer_under_mut_ref_hack
HACK(nilehmann) This let us infer parameters under mutable references for the simple case where the formal argument is of the form &mut B[@n], e.g., the type of the first argument to RVec::get_mut is &mut RVec<T>[@n]. We should remove this after we implement opening of mutable references.
is_indexed_mut_skipping_constr 🔒
unfold_local_ptrs
Temporarily (around a function call) convert an &mut to an &strg to allow for the call to be checked. This is done by unfolding the &mut into a local pointer at the call-site and then folding the pointer back into the &mut upon return. See also LocEnv::fold_local_ptrs.