Rollup merge of #108404 - ozkanonur:108004, r=jyn514

support `x fmt` for sub and outside of rust directories

This PR makes `x fmt` to be succesfully work from sub or outside dir of rust.

The following cases are tested and the results were successful.
```sh
# from rust/library directory
../x fmt compiler --check
../x fmt compiler/rustc

# from outside of rust directory
../../rust/x fmt library/std library/core --check
../../rust/x fmt library/std
```

Resolves #108004

r? ``@albertlarsan68``
This commit is contained in:
Matthias Krüger 2023-02-25 11:31:33 +01:00 committed by GitHub
commit 91a8496b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -218,7 +218,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
WalkBuilder::new(first)
}
} else {
WalkBuilder::new(first)
WalkBuilder::new(src.join(first))
};
for path in &paths[1..] {
@ -229,7 +229,7 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
walker.add(path);
}
} else {
walker.add(path);
walker.add(src.join(path));
}
}