Allow shortcuts to directories to be used for ./x.py fmt#107948
Allow shortcuts to directories to be used for ./x.py fmt#107948bors merged 1 commit intorust-lang:masterfrom
Conversation
|
r? @ozkanonur (rustbot has picked a reviewer for you, use r? to override) |
4645465 to
fdceb37
Compare
|
This change breaks the backwards compatibility of ~/devspace/personal/rust-dist/tools $ ../../rust/x.py fmt ../../rust/library/std
thread 'thread 'main' panicked at 'path is expected to be under the root', main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs/cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs::227227::99
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'thread 'main' panicked at 'mainpath is expected to be under the root' panicked at '', path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs/cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs::227227::99
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'thread 'mainmain' panicked at '' panicked at 'path is expected to be under the rootpath is expected to be under the root', ', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs/cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs::227:2279
:note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs:227:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Running `"/home/nimda/devspace/personal/rust-dist/tools/build/x86_64-unknown-linux-gnu/rustfmt/bin/rustfmt" "--config-path" "/home/nimda/devspace/personal/rust2" "--edition" "2021" "--unstable-features" "--skip-children" "../../rust/library/std/src/rt.rs" "../../rust/library/std/src/time.rs" "../../rust/library/std/src/sync/once/tests.rs" "../../rust/library/std/src/net/ip_addr.rs" "../../rust/library/std/src/net/mod.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
Build completed unsuccessfully in 0:00:56
thread 'main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs:227:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs:227:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs:227:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs:227:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'thread 'mainmain' panicked at '' panicked at 'path is expected to be under the rootpath is expected to be under the root', ', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs/cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs::227:9
227note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'thread 'mainmain' panicked at '' panicked at 'path is expected to be under the rootpath is expected to be under the root', ', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs/cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs::227227::99
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs:227:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs:227:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.18/src/gitignore.rs:227:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace |
src/bootstrap/format.rs
Outdated
There was a problem hiding this comment.
Seems this style is better:
if let Ok(entry) = candidate &&
let Some(dir_name) = p.file_name() &&
entry.path().is_dir() && entry.file_name() == dir_name {
...
}There was a problem hiding this comment.
I would love to use that, but for src/bootstrap/format.rs if-let chains features aren't already enabled
error[E0658]: `let` expressions in this position are unstable
--> format.rs:199:24
|
199 | if let Ok(entry) = candidate
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more informationI've been using if-let chains in compiler/ and it's been really nice. Should I enable the feature or have the code remain as-is?
There was a problem hiding this comment.
I think it's out of scope for this particular PR.
There was a problem hiding this comment.
Bootstrap itself is rarely (ever?) built with nightly.
The only thing to do is maybe leave a FIXME, but do not enable nightly features.
There was a problem hiding this comment.
Yes, please don't use nightly in bootstrap, if we start doing that we have to add cfg(bootstrap) to bootstrap itself and that will not be fun
There was a problem hiding this comment.
Ah right I forgot bootstrap needed to work with stable 😄, the PR was squashed as-is without touching nightly features.
|
Thanks for the quick fix! Please also consider review suggestion from @chenyukang, and then squash your commits into single one so we can take this into master. |
Fixes rust-lang#107944. Maximum recursive search depth is 3 and only accepts shortcuts for directories (single component paths, such as `./x.py fmt std`). If there are no shortcut candidates but single componenet path(s) are given, it falls back to the previous behavior to panic with unable to find directory. If there are multiple shortcut candidates for a given single component path, the shortcut candidates are considered ambiguous, are then ignored, and the single component path is accepted as-is. After this change, `./x.py fmt std` no longer panics and formats `library/std` instead.
6daaa64 to
b10d744
Compare
|
@bors r+ rollup |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#107902 (fix: improve the suggestion on future not awaited) - rust-lang#107913 (Update broken link in cargo style guide) - rust-lang#107942 (Tighter spans for bad inherent `impl` self types) - rust-lang#107948 (Allow shortcuts to directories to be used for ./x.py fmt) - rust-lang#107971 (Clearly document intentional UB in mir-opt tests) - rust-lang#107985 (Added another error to be processed in fallback) - rust-lang#108002 (Update books) - rust-lang#108013 (rustdoc: use a string with one-character codes for search index types) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #107944.
Maximum recursive search depth is 3 and only accepts shortcuts for directories. If there are no shortcut candidates, the previous behavior to panic is preserved. If there are multiple candidates, the shortcut candidates are ignored.
After this change,
./x.py fmt stdno longer panics and formatslibrary/stdinstead.