Skip to main content

MacroTable

Struct MacroTable 

Source
pub struct MacroTable { /* private fields */ }
Expand description

Every macro currently defined.

Implementations§

Source§

impl MacroTable

Source

pub fn new() -> MacroTable

An empty table.

Source

pub fn lookup(&self, name: Symbol) -> Option<&MacroDef>

The definition of name, if it has one.

Source

pub fn is_defined(&self, name: Symbol) -> bool

Whether name is defined, which is what #ifdef and defined ask.

Source

pub fn len(&self) -> usize

How many macros are defined.

Source

pub fn is_empty(&self) -> bool

Whether no macros are defined.

Source

pub fn define( &mut self, def: MacroDef, interner: &Interner, ) -> Option<Diagnostic>

Adds a definition, returning a warning if it replaces a different one.

Redefining a macro to the same thing is legal and extremely common, because a header included twice through two paths does it. Redefining it to something else is a constraint violation, which GCC reports as a warning and accepts, and we match that because rejecting it would break real builds.

Source

pub fn define_builtin(&mut self, name: Symbol, builtin: Builtin, span: Span)

Defines one of the macros whose value is a question.

span is where to say the macro came from, which is the start of <built-in>, so that a warning about redefining __FILE__ has somewhere to point.

Source

pub fn undef(&mut self, name: Symbol) -> Option<MacroDef>

Removes a definition. Undefining a macro that is not defined is legal and silent.

Source

pub fn sorted(&self) -> Vec<&MacroDef>

Every defined macro, sorted by symbol.

Sorted because -dM output has to be byte identical across runs and hash order is not, per spec/02-the-goal.md.

Trait Implementations§

Source§

impl Debug for MacroTable

Source§

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

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

impl Default for MacroTable

Source§

fn default() -> MacroTable

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

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