internal: Forbid canonicalization of paths and normalize all rust-project.json paths#14735
internal: Forbid canonicalization of paths and normalize all rust-project.json paths#14735bors merged 2 commits intorust-lang:masterfrom
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.
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