The SourceName and SourceFile structures for identifying files#260
Open
LesterEvSe wants to merge 1 commit intoBlockstreamResearch:dev/importsfrom
Open
The SourceName and SourceFile structures for identifying files#260LesterEvSe wants to merge 1 commit intoBlockstreamResearch:dev/importsfrom
SourceName and SourceFile structures for identifying files#260LesterEvSe wants to merge 1 commit intoBlockstreamResearch:dev/importsfrom
Conversation
KyrylR
requested changes
Mar 31, 2026
src/resolution.rs
Outdated
Comment on lines
+5
to
+10
| /// Identifies the origin of a piece of source code. | ||
| #[derive(Clone, Debug, Eq, PartialEq, Hash)] | ||
| pub enum SourceName { | ||
| /// A physical file located on the filesystem. | ||
| Real(Arc<Path>), | ||
| /// An in-memory or virtual source (e.g., `<repl>`, `<unknown>`, or test data). |
Collaborator
There was a problem hiding this comment.
Could you elaborate more on what is your vision for using this?
I do not understand what virtual is
Collaborator
Author
There was a problem hiding this comment.
It can be used for error handling in tests or in one-file programs passed as a raw string. It could also be useful in the future if our libraries were in a GH repo rather than on a local disk, as we would not be able to write a real path for them and would need a virtual one.
Collaborator
There was a problem hiding this comment.
We should include this explanation to docs as well then
src/resolution.rs
Outdated
Comment on lines
+14
to
+23
| impl SourceName { | ||
| /// Returns a new `SourceName` with the file extension removed. | ||
| /// Virtual sources are returned unchanged. | ||
| pub fn without_extension(&self) -> SourceName { | ||
| match self { | ||
| SourceName::Real(path) => SourceName::Real(Arc::from(path.with_extension(""))), | ||
| SourceName::Virtual(name) => SourceName::Virtual(name.clone()), | ||
| } | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
Let's add this block when it is actually used
f1432c8 to
4f0f9a1
Compare
4f0f9a1 to
5383d35
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the
SourceNameandSourceFileabstractions to track the origin of parsed code. With the help of these two structures, we can accurately identify source files and lay the groundwork for proper error diagnostics across multiple files in the future.