Skip to main content

Attributes

Struct Attributes 

Source
pub struct Attributes {
Show 15 fields pub noreturn: Option<SourceRange>, pub always_inline: Option<SourceRange>, pub noinline: Option<SourceRange>, pub cold: Option<SourceRange>, pub deprecated: Option<Spanned<Option<String>>>, pub packed: Option<SourceRange>, pub aligned: Option<Alignment>, pub section: Option<Spanned<String>>, pub target: Vec<Spanned<String>>, pub constructor: Option<SourceRange>, pub destructor: Option<SourceRange>, pub cleanup: Option<Cleanup>, pub mode: Option<Spanned<String>>, pub safe: Option<SourceRange>, pub weak: Option<SourceRange>,
}
Expand description

What an attribute specifier sequence asked for.

Both spellings — GNU’s __attribute__((…)) and C23’s [[…]] — produce this, because they say the same things. Everything the front end does not act on is dropped while it is parsed, which C23 6.7.13.1p3 explicitly allows and which GCC does with a warning this crate has no way to raise.

Fields§

§noreturn: Option<SourceRange>

noreturn / [[noreturn]], which says exactly what _Noreturn says.

§always_inline: Option<SourceRange>

always_inline.

§noinline: Option<SourceRange>

noinline.

§cold: Option<SourceRange>

cold; hot clears it again, as GCC’s do.

§deprecated: Option<Spanned<Option<String>>>

deprecated, with the message it was given.

§packed: Option<SourceRange>

packed, on a record or on one member.

§aligned: Option<Alignment>

aligned(N), which is the same request _Alignas(N) makes.

§section: Option<Spanned<String>>

section("…").

§target: Vec<Spanned<String>>

target("avx2"), target("sse4.2,popcnt"), target("avx2", "fma"): the instruction sets the function is compiled for, one entry per name, in GCC’s spelling and with the range of the attribute that wrote it.

Also what #pragma GCC target leaves behind for the functions after it; the parser puts the pragma’s list here when the declaration writes no attribute of its own.

§constructor: Option<SourceRange>

constructor, whose priority is parsed and ignored.

§destructor: Option<SourceRange>

destructor, likewise.

§cleanup: Option<Cleanup>

cleanup(f), on a variable with automatic storage duration.

§mode: Option<Spanned<String>>

mode(M), which replaces the declared type with the one the machine mode names, keeping its signedness.

§safe: Option<SourceRange>

[[cinrs::safe]] / __attribute__((cinrs_safe)): generate the function without unsafe, so that rustc checks its body.

This crate’s own attribute rather than one of GCC’s, which is why it is spelled in this crate’s namespace both ways.

§weak: Option<SourceRange>

weak, which only sema can answer: it is refused on a definition and accepted on a declaration.

Implementations§

Source§

impl Attributes

Source

pub fn is_empty(&self) -> bool

Whether nothing was asked for.

Source

pub fn merge(&mut self, other: Attributes)

Everything either sequence asked for.

GCC lets the attributes of one declaration be spread over the specifiers, the declarator and the definition, and takes the union.

Trait Implementations§

Source§

impl Clone for Attributes

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 Debug for Attributes

Source§

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

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

impl Default for Attributes

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Attributes

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 Attributes

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.