pub enum Attribute {
Show 19 variants
Noreturn,
AlwaysInline,
NoInline,
Cold,
Hot,
Deprecated,
Fallthrough,
Packed,
Aligned,
Section,
Target,
Constructor,
Destructor,
Cleanup,
Mode,
Safe,
Weak,
Unsupported,
Ignored,
}Expand description
What an __attribute__ (or a C23 [[…]]) asks for.
Variants§
Noreturn
noreturn, _Noreturn: a call to the function does not come back.
AlwaysInline
always_inline: #[inline(always)].
NoInline
noinline: #[inline(never)].
Cold
cold, and hot as its opposite: #[cold].
Hot
hot, which cancels cold.
Deprecated
deprecated: #[deprecated].
Fallthrough
fallthrough, which is a statement attribute and means nothing here —
a switch group falls through in the generated Rust either way.
Packed
packed: no padding, on a record or on one member.
Aligned
aligned(N): raise the alignment.
Section
section("…"): #[unsafe(link_section = "…")].
Target
target("avx2"): #[target_feature(enable = "avx2")], which is what
lets a function use an instruction set above the target’s baseline.
Constructor
constructor, optionally with a priority: run before main.
Destructor
destructor, likewise: run after it.
Cleanup
cleanup(f): call f(&x) when x goes out of scope.
Mode
mode(M): the declared type is the one the machine mode names.
Safe
cinrs_safe, and [[cinrs::safe]]: this crate’s own attribute, which
generates the function without unsafe so that rustc checks it.
Weak
weak: the symbol may be missing at link time, and its address is then
null. Refused on a definition, where Rust’s unstable #[linkage]
would be the only way to say it, and ignored on a declaration; see
crate::sema.
Unsupported
asm("symbol") written as an attribute is not a thing, but
alias, weakref and the rest are: known, and refused with the reason.
Ignored
Known and safe to ignore: a hint, a diagnostic request, or something the generated Rust cannot observe.