pub struct SourceFile { /* private fields */ }Expand description
A single file of C source together with its Rust-token anchors.
Implementations§
Source§impl SourceFile
impl SourceFile
Sourcepub fn range(&self) -> SourceRange
pub fn range(&self) -> SourceRange
The range this file occupies in the global offset space.
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Number of lines in the file (at least 1).
Sourcepub fn rust_path(&self) -> Option<&str>
pub fn rust_path(&self) -> Option<&str>
The .rs file this text was written in, when the compiler knows it.
This is what the preprocessor’s __FILE__ expands to; it is None
outside a real macro expansion (a unit test building a TokenStream
from a string) and for #included files, which name themselves.
Sourcepub fn first_line(&self) -> usize
pub fn first_line(&self) -> usize
The 1-based line of the enclosing .rs file that this file’s line 1
sits on; 1 when nothing better is known.
The preprocessor adds this to a position’s own line to make __LINE__
a number that matches what an editor shows.
Sourcepub fn is_included(&self) -> bool
pub fn is_included(&self) -> bool
Whether this file is one whose diagnostics name it themselves: an
#included header, or the .c file of an include_c99!.
Neither has a span of its own — the caret lands on the #include or on
the macro invocation — so file:line:column goes into the message
instead; see SourceMap::header_position.