From 3309ff9fe5ea36134e8ddf11ac2c84613b569856 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 25 May 2022 11:16:03 +0200 Subject: Slim down context --- src/source.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/source.rs') diff --git a/src/source.rs b/src/source.rs index 7973a2ee..cd5a453a 100644 --- a/src/source.rs +++ b/src/source.rs @@ -59,6 +59,16 @@ impl SourceStore { } } + /// Get a reference to a loaded source file. + /// + /// This panics if no source file with this `id` exists. This function + /// should only be called with ids returned by this store's + /// [`load()`](Self::load) and [`provide()`](Self::provide) methods. + #[track_caller] + pub fn get(&self, id: SourceId) -> &SourceFile { + &self.sources[id.0 as usize] + } + /// Load a source file from a path relative to the compilation environment's /// root. /// @@ -109,14 +119,6 @@ impl SourceStore { id } - /// Get a reference to a loaded source file. - /// - /// This panics if no source file with this `id` exists. - #[track_caller] - pub fn get(&self, id: SourceId) -> &SourceFile { - &self.sources[id.0 as usize] - } - /// Fully [replace](SourceFile::replace) the source text of a file. /// /// This panics if no source file with this `id` exists. -- cgit v1.2.3