Skip to main content

Builtin

Struct Builtin 

Source
pub struct Builtin {
    pub set: BuiltinSet,
    pub longs: u8,
    pub width: Option<ExprId>,
}
Expand description

The keywords naming a built-in type, as the multiset that was written.

Kept rather than resolved, because the parser reads one keyword at a time and cannot tell what long will turn out to mean until the specifier list ends. Builtin::add catches a keyword written twice, at the place it is written, and Builtin::resolve catches a combination that names no type once there are no more keywords coming.

Fields§

§set: BuiltinSet

Which keywords were written.

§longs: u8

How many times long was written, since it is the one that may repeat.

§width: Option<ExprId>

The width of the _BitInt, for the one keyword here that takes one.

Implementations§

Source§

impl Builtin

Source

pub const NONE: Builtin

Nothing written yet.

Source

pub const fn add(self, which: BuiltinSet) -> Result<Builtin, BuiltinError>

This with one more keyword.

long is the only keyword that may be written twice, so everything else is a duplicate the second time and is reported at the keyword rather than at the end of the specifier list, which is where the second half of the checking happens.

§Errors

BuiltinError::Duplicate for a repeat, and BuiltinError::TooManyLongs for a third long.

Source

pub const fn add_bit_int(self, width: ExprId) -> Result<Builtin, BuiltinError>

This with _BitInt(width) written into it.

The width is the one thing a type keyword carries, and it is kept here rather than in a specifier of its own so that unsigned _BitInt(8) and _BitInt(8) unsigned are the same declaration, which is what they are: a sign and a width may be written either way round, and neither of them names a type on its own.

§Errors

BuiltinError::Duplicate when _BitInt was already written.

Source

pub const fn is_none(self) -> bool

Whether any built-in keyword has been written.

Source

pub fn resolve(self) -> Option<Basic>

The type this combination of keywords names, and None if it names no type.

The table is the one in 6.7.2 plus the GNU and C23 rows: _Complex and _Imaginary on the floating types, _Complex on the integer ones which GCC also allows, __int128 with a sign, and the _FloatN and _DecimalN families which stand alone.

Trait Implementations§

Source§

impl Clone for Builtin

Source§

fn clone(&self) -> Builtin

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 Builtin

Source§

impl Debug for Builtin

Source§

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

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

impl Default for Builtin

Source§

fn default() -> Builtin

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

impl Eq for Builtin

Source§

impl PartialEq for Builtin

Source§

fn eq(&self, other: &Builtin) -> 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 Builtin

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, <T as TryFrom<U>>::Error>

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.