pub trait AsFnAndArgs<'tcx> {
// Required method
fn as_instance_and_args(
&self,
tcx: TyCtxt<'tcx>,
) -> Result<(Instance<'tcx>, SimplifiedArguments<'tcx>, Place<'tcx>), AsFnAndArgsErr<'tcx>>;
// Provided method
fn as_fn_and_args(
&self,
tcx: TyCtxt<'tcx>,
) -> Result<(DefId, SimplifiedArguments<'tcx>, Place<'tcx>), AsFnAndArgsErr<'tcx>> { ... }
}
Expand description
Extension trait for function calls (e.g. mir::TerminatorKind
and
mir::Terminator
) that lets you decompose the call into a convenient
(function definition, arguments, return place) tuple in such cases when
a. The terminator is a function call (i.e. mir::TerminatorKind::Call
)
b. The callee can be statically determined (i.e. not an opaque function
pointer).
The error message conveys which of these assumptions failed.
The argument vector contains None
in those places where the function is
called with a constant. This means it is guaranteed to be as long as the
list of formal parameters of this function, which in turn means it can be
zipped up with e.g. the types of the arguments of the function definition