-
Notifications
You must be signed in to change notification settings - Fork 11.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[move] Fix vfs relativization #16987
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -347,7 +339,7 @@ impl Compiler { | |||
|
|||
source_text | |||
.iter_mut() | |||
.for_each(|(_, (path, _))| *path = relativize_path(&vfs_root, *path)); | |||
.for_each(|(_, (path, _))| *path = vfs_to_original_path[path]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This map access should not be unconditional as new paths can be generated between when the map is initialized and when it's used here, so not every path will have an entry in the map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I found out as much from tests. Attempting to fix but it might blow up on windows
let paths: Vec<Symbol> = if vfs_root.is_none() { | ||
let paths: Vec<_> = paths.into_iter().map(|p| p.into()).collect(); | ||
let paths: Vec<_> = paths.iter().map(|p| p.as_str()).collect(); | ||
find_filenames_and_keep_specified(&paths, &mut find_move_files)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I want to get the compiler out of the business of finding files. It is a relic from before the package system. But its functionality is relied on a bit too much to rip out from this PR, though I totally can if y'all want me to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a very large fan of ripping it out as soon as possible.
// TODO this should really be done by the package system, with the interface files stuffed into the | ||
// build/ directory for the package. This would give a more consistent location for errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking of pre-package system relics... it would be really great to make this a package system feature someday
pub fn set_compiler_vfs_root(mut self, vfs_root: VfsPath) -> Self { | ||
assert!(self.compiler_vfs_root.is_none()); | ||
self.compiler_vfs_root = Some(vfs_root); | ||
self | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this very unsatisfying, but am unsure what to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be std::mem::replace
where you hand back the old one and make the caller deal with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than a nit, LGTM
.collect::<Result<Vec<_>, anyhow::Error>>()?; | ||
|
||
for path in targets.iter().chain(&deps) { | ||
if !path.path.is_file().unwrap_or(false) { | ||
debug_assert!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the assertion since we are bailing anyways?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want the assertion so we get a panic instead of an Err in debug builds
let vfs = p.to_vfs_path(&vfs_root)?; | ||
vfs_to_original_path.insert(Symbol::from(vfs.path.as_str()), original); | ||
Ok(vfs) | ||
}) | ||
.collect::<Result<Vec<_>, anyhow::Error>>()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something to mention is there were some build issues in migration where two packages pointed to the same dependency via different relative paths, and those got reported as conflicting even though they were the same. I don't think we should fix that in this PR, but I suspect it may impact some of this code.
let mut files = file_paths | ||
.into_iter() | ||
.map(path_to_string) | ||
.collect::<anyhow::Result<Vec<String>>>()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be filtered by is_file_desired
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the intention of this function versus find_files is to keep any file specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, modulo the nit above and a few small questions.
Description
Test Plan
If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section.
Type of Change (Check all that apply)
Release notes
Fixed issues with
sui move
not working incmd.exe
on Windows.