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§
Enums§
- SubFn
SubFnlets us reuse most of the same code forcheck_fn_subtypingfor 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_subtypingdoes a function subtyping check between the sub-type (T_f) corresponding to the type ofdef_id@argsand the super-type (T_g) corresponding to theoblig_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 toRVec::get_mutis&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
&mutto an&strgto allow for the call to be checked. This is done by unfolding the&mutinto a local pointer at the call-site and then folding the pointer back into the&mutupon return. See alsoLocEnv::fold_local_ptrs.