pub trait InferCtxtExt<'tcx> {
// Required methods
fn get_fn_like_arguments(
&self,
node: Node<'_>
) -> Option<(Span, Option<Span>, Vec<ArgKind>)>;
fn report_arg_count_mismatch(
&self,
span: Span,
found_span: Option<Span>,
expected_args: Vec<ArgKind>,
found_args: Vec<ArgKind>,
is_closure: bool,
closure_pipe_span: Option<Span>
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>;
fn type_implements_fn_trait(
&self,
param_env: ParamEnv<'tcx>,
ty: Binder<'tcx, Ty<'tcx>>,
polarity: ImplPolarity
) -> Result<(ClosureKind, Binder<'tcx, Ty<'tcx>>), ()>;
}
Required Methods§
sourcefn get_fn_like_arguments(
&self,
node: Node<'_>
) -> Option<(Span, Option<Span>, Vec<ArgKind>)>
fn get_fn_like_arguments( &self, node: Node<'_> ) -> Option<(Span, Option<Span>, Vec<ArgKind>)>
Given some node representing a fn-like thing in the HIR map,
returns a span and ArgKind
information that describes the
arguments it expects. This can be supplied to
report_arg_count_mismatch
.
sourcefn report_arg_count_mismatch(
&self,
span: Span,
found_span: Option<Span>,
expected_args: Vec<ArgKind>,
found_args: Vec<ArgKind>,
is_closure: bool,
closure_pipe_span: Option<Span>
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>
fn report_arg_count_mismatch( &self, span: Span, found_span: Option<Span>, expected_args: Vec<ArgKind>, found_args: Vec<ArgKind>, is_closure: bool, closure_pipe_span: Option<Span> ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>
Reports an error when the number of arguments needed by a trait match doesn’t match the number that the expression provides.
sourcefn type_implements_fn_trait(
&self,
param_env: ParamEnv<'tcx>,
ty: Binder<'tcx, Ty<'tcx>>,
polarity: ImplPolarity
) -> Result<(ClosureKind, Binder<'tcx, Ty<'tcx>>), ()>
fn type_implements_fn_trait( &self, param_env: ParamEnv<'tcx>, ty: Binder<'tcx, Ty<'tcx>>, polarity: ImplPolarity ) -> Result<(ClosureKind, Binder<'tcx, Ty<'tcx>>), ()>
Checks if the type implements one of Fn
, FnMut
, or FnOnce
in that order, and returns the generic type corresponding to the
argument of that trait (corresponding to the closure arguments).