-
Notifications
You must be signed in to change notification settings - Fork 1.8k
internal: Forbid canonicalization of paths and normalize all rust-project.json paths #14735
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
Conversation
r? @matklad (the stackoverflow post you linked outlines that clang also accepts relative paths to base, but I think given for this file we expect it to be generated anyways there is little use for allowing that) |
Note to self: Comment on #4887 regarding the changes from this PR |
Tbh, I’d keep relative paths, resolving relative to the location of the file seems like a common idiom, and it’s convenient to, eg, have several checkouts in different dirs using git worktree, or to check the file into VCS. What we should avoid is cwd-relative paths, but that’s why the abspath infra exists. |
8beee3f
to
939ebb4
Compare
ProjectJson { | ||
sysroot: data.sysroot.map(|it| base.join(it)), | ||
sysroot_src: data.sysroot_src.map(|it| base.join(it)), | ||
sysroot: data.sysroot.map(absolutize), |
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.
just
data.sysroot.map(|it| base.join(it)),
should do the trick. That's the semantics of Rust's join: if the path is absolute, base is ignored. It is a bit surprising, perhaps we can benefit from
impl AbsPath {
pub fn absolutize(&self, path: impl AsRef<Path>) -> AbsPathBuf;
pub fn join(&self, path: &RelPath) -> AbsPathBuf;
}
impl RelPath {
pub fn join(&self, path: &RelPath) -> RelPathBuf;
}
@bors r+ |
☀️ Test successful - checks-actions |
Closes #14728
cc #14430