Skip to main content

Attribute

Enum Attribute 

Source
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.

Trait Implementations§

Source§

impl Clone for Attribute

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Attribute

Source§

impl Debug for Attribute

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Attribute

Source§

impl PartialEq for Attribute

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Attribute

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.