Skip to main content

SyntaxIrFile

Struct SyntaxIrFile 

Source
pub struct SyntaxIrFile {
    pub language: Language,
    pub frontend_version: &'static str,
    pub ir_schema_version: u32,
    pub tokens: Vec<Token>,
    pub roots: Vec<IrNode>,
    pub diagnostics: Vec<Diagnostic>,
    pub error_ranges: Vec<ByteRange>,
    pub depth_truncated: bool,
    pub test_module: bool,
}
Expand description

The Syntax IR of one source file.

Fields§

§language: Language

Language the file was parsed as.

§frontend_version: &'static str

Version tag of the structural frontend that produced this IR; a fingerprint input alongside IR_SCHEMA_VERSION.

§ir_schema_version: u32

IR schema version this file conforms to.

§tokens: Vec<Token>

Tokens in source order, comments and whitespace removed. Same representation as Fast mode, so token-level normalization is shared.

§roots: Vec<IrNode>

Top-level IR nodes in source order.

§diagnostics: Vec<Diagnostic>

Recoverable lexical problems, as in Fast mode.

§error_ranges: Vec<ByteRange>

Source regions the parser marked as errors. Overlapping nodes are still emitted; these ranges only lower confidence downstream.

§depth_truncated: bool

Whether the frontend stopped descending after reaching its structural depth budget.

This is deliberately separate from Self::error_ranges: malformed source is ordinary recovery, while a depth ceiling means the scan was intentionally incomplete and must be reported as such.

§test_module: bool

Whether the file is the body of a module its tree declares test-only.

Not something a parse can answer: the declaration carrying the marker is in another file, so this is settled once the whole set is known and left here for the walk that reads a unit’s markers to start from. A frontend leaves it false. See declared_test_modules.

Implementations§

Source§

impl SyntaxIrFile

Source

pub fn walk(&self, visit: &mut impl FnMut(&IrNode))

Depth-first pre-order traversal over every node in the file.

Source

pub fn node_count(&self) -> usize

Total number of nodes in the file.

Source

pub fn unaccounted_tokens(&self) -> usize

Tokens the parser could not attach to any structure: those inside a Shape::Error node that none of its children recovered.

This is the honest measure of what a parse lost, and error_ranges is not. An error-tolerant parser recovering from one bad construct routinely wraps everything around it in a single error node: a header whose include guard encloses the file gets one error region covering every byte of it, with the whole file’s declarations intact inside. Measured over one project’s C++ sources, the error regions covered 13.3% of the bytes while the tokens that actually failed to parse were 1.82% — the difference is entirely code the parser did read, sitting inside a region it had to open.

Nesting is not double-counted: an error node inside another is covered by its parent’s children, so the parent contributes only the gaps around it and the child contributes its own.

Trait Implementations§

Source§

impl Clone for SyntaxIrFile

Source§

fn clone(&self) -> SyntaxIrFile

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 SyntaxIrFile

Source§

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

Formats the value using the given formatter. 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> 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> 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 = Infallible

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.