pub struct SourceMap { /* private fields */ }Expand description
The compiler’s registry of source files.
Interning is append-only: once a file has an id its text and path are fixed for the lifetime of the map, which keeps diagnostics and snapshots stable. The map is internally synchronized so it can be shared across threads (the LSP, for example, reads source from a background query thread).
Implementations§
Source§impl SourceMap
impl SourceMap
Sourcepub fn intern(
&self,
path: impl Into<PathBuf>,
text: impl Into<String>,
) -> FileId
pub fn intern( &self, path: impl Into<PathBuf>, text: impl Into<String>, ) -> FileId
Intern a source file under the given path, returning its id.
Each call mints a fresh id even for a repeated path: a later load of the same path is treated as a distinct snapshot. This matches the §13.1 “revisioned source” model — the LSP holds several revisions of one file simultaneously.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SourceMap
impl RefUnwindSafe for SourceMap
impl Send for SourceMap
impl Sync for SourceMap
impl Unpin for SourceMap
impl UnsafeUnpin for SourceMap
impl UnwindSafe for SourceMap
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
Mutably borrows from an owned value. Read more