Skip to main content

## FnAbiOf

# Trait FnAbiOf

Source

    pub trait FnAbiOf<'tcx>: FnAbiOfHelpers<'tcx> {
        // Provided methods
        fn fn_abi_of_fn_ptr(
            &self,
            sig: PolyFnSig<'tcx>,
            extra_args: &'tcx List<Ty<'tcx>>,
        ) -> Self::FnAbiOfResult { ... }
        fn fn_abi_of_instance_no_deduced_attrs(
            &self,
            instance: Instance<'tcx>,
            extra_args: &'tcx List<Ty<'tcx>>,
        ) -> Self::FnAbiOfResult { ... }
        fn fn_abi_of_instance(
            &self,
            instance: Instance<'tcx>,
            extra_args: &'tcx List<Ty<'tcx>>,
        ) -> Self::FnAbiOfResult { ... }
    }

Expand description

Blanket extension trait for contexts that can compute `FnAbi`s.

## Provided Methods§

Source

#### fn fn_abi_of_fn_ptr( &self, sig: PolyFnSig<'tcx>, extra_args: &'tcx List<Ty<'tcx>>, ) -> Self::FnAbiOfResult

Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.

NB: this doesn’t handle virtual calls - those should use `fn_abi_of_instance` instead, where the instance is an `InstanceKind::Virtual`.

Source

#### fn fn_abi_of_instance_no_deduced_attrs( &self, instance: Instance<'tcx>, extra_args: &'tcx List<Ty<'tcx>>, ) -> Self::FnAbiOfResult

Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for direct calls* to an `fn`. Indirectly-passed parameters in the returned ABI might not include all possible codegen optimization attributes (such as `ReadOnly` or `CapturesNone`), as deducing these requires inspection of function bodies that can lead to cycles when performed during typeck. Post typeck, you should prefer the optimized ABI returned by `fn_abi_of_instance`.

NB: the ABI returned by this query must not differ from that returned by `fn_abi_of_instance` in any other way.

- that includes virtual calls, which are represented by “direct calls” to an `InstanceKind::Virtual` instance (of `<dyn Trait as Trait>::fn`).

Source

#### fn fn_abi_of_instance( &self, instance: Instance<'tcx>, extra_args: &'tcx List<Ty<'tcx>>, ) -> Self::FnAbiOfResult

Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for direct calls* to an `fn`. Indirectly-passed parameters in the returned ABI will include applicable codegen optimization attributes, including `ReadOnly` and `CapturesNone` – deduction of which requires inspection of function bodies that can lead to cycles when performed during typeck. During typeck, you should therefore use instead the unoptimized ABI returned by `fn_abi_of_instance_no_deduced_attrs`.

- that includes virtual calls, which are represented by “direct calls” to an `InstanceKind::Virtual` instance (of `<dyn Trait as Trait>::fn`).

## Implementors§

Source§

### impl<'tcx, C: FnAbiOfHelpers<'tcx>> FnAbiOf<'tcx> for C