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: boolWhether 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: boolWhether 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§
impl Eq for MacroAt
impl StructuralPartialEq for MacroAt
Auto Trait Implementations§
impl Forget for MacroAt
impl Freeze for MacroAt
impl RefUnwindSafe for MacroAt
impl Send for MacroAt
impl Sync for MacroAt
impl Unpin for MacroAt
impl UnsafeUnpin for MacroAt
impl UnwindSafe for MacroAt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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