Module builtin
Definitions of built-in macros.
Most of the macro properties (stability, visibility, etc.) are taken from the source code here, with exception of expansion functions transforming macro inputs into outputs, those functions are provided by the compiler.
Macros
-
From
Derive macro generating an impl of the trait
From. Currently, it can only be used on single-field structs. - alloc_error_handler Attribute macro applied to a function to register it as a handler for allocation failure.
- autodiff_forward This macro uses forward-mode automatic differentiation to generate a new function. It may only be applied to a function. The new function will compute the derivative of the function to which the macro was applied.
- autodiff_reverse This macro uses reverse-mode automatic differentiation to generate a new function. It may only be applied to a function. The new function will compute the derivative of the function to which the macro was applied.
- bench Attribute macro applied to a function to turn it into a benchmark test.
- cfg_accessible Keeps the item it's applied to if the passed path is accessible, and removes it otherwise.
-
cfg_eval
Expands all
#[cfg]and#[cfg_attr]attributes in the code fragment it's applied to. - contracts_ensures Attribute macro applied to a function to give it a post-condition.
- contracts_requires Attribute macro applied to a function to give it a precondition.
- define_opaque Provide a list of type aliases and other opaque-type-containing type definitions to an item with a body. This list will be used in that body to define opaque types' hidden types. Can only be applied to things that have bodies.
- deref Unstable placeholder for deref patterns.
- derive Attribute macro used to apply derive macros.
- derive_const Attribute macro used to apply derive macros for implementing traits in a const context.
- eii Externally Implementable Item: Defines an attribute macro that can override the item this is applied to.
- eii_declaration Impl detail of EII
- global_allocator Attribute macro applied to a static to register it as a global allocator.
-
offload_kernel
The
offload_kernelmacro is applied to a function to generate two separate definitions: a host-side wrapper for dispatch and a device-side kernel. - test Attribute macro applied to a function to turn it into a unit test.
-
test_case
An implementation detail of the
#[test]and#[bench]macros. - type_ascribe Unstable placeholder for type ascription.
- unsafe_eii Unsafely Externally Implementable Item: Defines an unsafe attribute macro that can override the item this is applied to.