Skip to main content

MacroAt

Struct MacroAt 

Source
pub struct MacroAt {
    pub defined: bool,
    pub body: Option<MacroBody>,
    pub body_text: Option<String>,
    pub function_like: bool,
    pub written_in: Option<PathBuf>,
    pub written_at_line: Option<usize>,
}
Expand description

What a name is at one position in one file — the question a preprocessor asks and the one this crate could not previously answer about a file it had only read.

Everything needed to answer it was already here; what was missing was a public door. The only way to ask it was to copy the file, inject an #error probe, and read the compiler’s complaint — and that probe changes the thing being measured. Measured, and the reason this type exists:

the real `xtr1common`                      → cl emits [[msvc::no_specializations(...)]] 17 times
a copy with `#error` probes inserted       → cl says the attribute is NOT supported (0)

A copy is not the file: an include guard, an include order, or a #pragma push_macro further up all move when the text moves. So the answer has to come from the analysis’s own timeline, which is what this reads.

Fields§

§defined: bool

Whether the name is a macro there. false covers both “undefined” and “#undefed above this line”.

§body: Option<MacroBody>

The shape of the replacement list, when the walk recovered one.

A cpp_parser::MacroBody rather than the body’s text, because that is what a later parse needs to know: whether the name expands to a type, a statement, an expression or nothing. The text is in MacroAt::body_text, which is what a reader wants. None with MacroAt::defined true is a name the walk saw defined but whose shape it could not read — an honest gap rather than a claim that the body is empty.

§body_text: Option<String>

The replacement list as written — what answers “so what does this name expand to?”.

§function_like: bool

Whether the definition takes arguments.

§written_in: Option<PathBuf>

Where the binding in force was written: the file, and the offset in it. None when the binding came from outside the unit — a compiler builtin or a command-line -D.

§written_at_line: Option<usize>

The line in MacroAt::written_in, one-based.

Trait Implementations§

Source§

impl Clone for MacroAt

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 MacroAt

Source§

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

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

impl Eq for MacroAt

Source§

impl PartialEq for MacroAt

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 MacroAt

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.