Skip to main content

Module improper_ctypes

Module improper_ctypes 

Source

StructsΒ§

ImproperCTypesLint
ImproperCTypesVisitor πŸ”’
Visitor used to recursively traverse MIR types and evaluate FFI-safety. It uses check_* methods as entrypoints to be called elsewhere, and visit_* methods to recurse.
RootUseFlags πŸ”’
VisitorState flags that are linked with the root type’s use. (These are the permanent part of the state, kept when visiting new Ty.)
VisitorState πŸ”’

EnumsΒ§

CItemKind πŸ”’
Annotates whether we are in the context of an item defined in rust and exposed to an FFI boundary, or the context of an item from elsewhere, whose interface is re-declared in rust.
FfiResult πŸ”’
FnPos πŸ”’
Annotates whether we are in the context of a function’s argument types or return type.
IndirectionKind πŸ”’
What type indirection points to a given type.
OuterTyKind πŸ”’
Description of the relationship between current Ty and the type (or lack thereof) immediately containing it

StaticsΒ§

IMPROPER_CTYPES πŸ”’
The improper_ctypes lint detects incorrect use of types in foreign modules.
IMPROPER_CTYPES_DEFINITIONS πŸ”’
The improper_ctypes_definitions lint detects incorrect use of extern function definitions.
USES_POWER_ALIGNMENT πŸ”’
The uses_power_alignment lint detects specific repr(C) aggregates on AIX. In its platform C ABI, AIX uses the β€œpower” (as in PowerPC) alignment rule (detailed in https://www.ibm.com/docs/en/xl-c-and-cpp-aix/16.1?topic=data-using-alignment-modes#alignment), which can also be set for XLC by #pragma align(power) or -qalign=power. Aggregates with a floating-point type as the recursively first field (as in β€œat offset 0”) modify the layout of subsequent fields of the associated structs to use an alignment value where the floating-point type is aligned on a 4-byte boundary.

FunctionsΒ§

check_arg_for_power_alignment πŸ”’
Per-struct-field function that checks if a struct definition follows the Power alignment Rule (see the check_struct_for_power_alignment function).
check_non_exhaustive_variant πŸ”’
Check a variant of a non-exhaustive enum for improper ctypes
check_struct_for_power_alignment πŸ”’
Check a struct definition for respect of the Power alignment Rule (as in PowerPC), which should be respected in the β€œaix” target OS. To do so, we must follow one of the two following conditions:
maybe_normalize_erasing_regions πŸ”’
A common pattern in this lint is to attempt normalize_erasing_regions, but keep the original type if it were to fail. This may or may not be supported in the logic behind the Unnormalized wrapper, (FIXME?) but it should be enough for non-wrapped types to be as normalised as this lint needs them to be.
variant_has_complex_ctor πŸ”’

Type AliasesΒ§

PartialFfiResult πŸ”’
The result when a type has been checked but perhaps not completely. None indicates that FFI safety/unsafety has not yet been determined, Some(res) indicates that the safety/unsafety in the FfiResult is final.