Give a hard error if `-Zrustdoc-scrape-examples` is missing a flag
It's the same as if the option wasn't passed, and it makes it difficult to
figure out why rustdoc isn't generating examples.
Fixes https://github.com/rust-lang/cargo/issues/10042 (cc `@willcrichton)`
silly fix, pointer to the empty slice
Just a silly thing. I don't know when this was fixed. NLL? But we no longer need a real Vec to produce a pointer to the empty slice.
Warn when alias shadows external subcommand
As per #10049, we start by emitting a warning when an alias shadows an
existing external subcommand. After a transition period (duration not
specified), we will make this a hard error.
Should the warning mention that this will become a hard error?
Implement escaping to allow clean -p to delete all files when directory contains glob characters
Closes#10068.
Runs `glob::Pattern::escape` on path input to `rm_rf_glob()`. This fixes a bug in which `cargo clean -p` fails to delete a number of files from `target/` if the path to target contains glob characters.
Match any error when failing to find executables
For Windows targets, Rust now uses [a custom resolver](https://github.com/rust-lang/rust/pull/87704) to find `process::Command` programs. This has caused some error messages to change.
To allow the PR to be merged, some tests have been adjusted to match any error.
cc `@ehuss`
Enhance error message for target auto-discovery
resolves#9014resolves#9117
Enhance for following scenarios:
1. Target without `path` specified and cannot be found.
2. Target without `path` specified and cannot be found, but a file
exists at the commonly wrong path, e.g. `example/a.rs`, `bench/b.rs`.
3. Found multiple candidate files and cannot infer which to use.
For the suggestion in [the thread in #9116], I can't see any feasible way to list potential candidates without addditional I/O checking file existences. This PR is the best effort I can think of at this time. Feel free to comment. Thanks!
[the thread in #9116]: https://github.com/rust-lang/cargo/pull/9116#discussion_r575712762
For Windows targets, Rust now uses a custom resolver to find `process::Command` programs. This has caused some error messages to change.
To allow it to be merged, some tests have been adjusted to match any error.
Enhance for following scenarios:
1. Target without `path` specified and cannot be found.
2. Target without `path` specified and cannot be found, but a file
exists at the commonly wrong path, e.g. `example/a.rs`, `bench/b.rs`.
3. Found multiple candidate files and cannot infer which to use.
Implement glob escaping for clean -p
Add pattern escape for glob matching cargo clean files
Implement correct solution for #10068
Removed superfluous formatting changes
Update rm_rf_glob()'s error handling
Remove dir_glob reference for non-glob function
Added test
Satisfy clippy
Add MSVC support for test
Include note about bug while building on macOS in mdbook
See https://github.com/rust-lang/rust/issues/90342. I can watch the thread and push another PR to delete this note once this bug is resolved.
As per #10049, we start by emitting a warning when an alias shadows an
existing external subcommand. After a transition period (duration not
specified), we will make this a hard error.
Fix debug panic on download with redirect body.
With a debug build of cargo, downloading crates can panic if the download host issues a redirect with a body. From what I can see, the curl progress function gets called with the original size of the redirect body (such as total=154 cur=154, indicating that it has read 154 bytes of the redirect message). Then it calls the progress function again with cur=0 to start again from the beginning. The next line in this patch, `cur - dl.current.get()` would panic since it is a `u64` and a 0 value of `cur` is less than the old `current`.
This was never really an issue with crates.io because it emits a redirect body of 0 bytes.
I think it is fine to skip this block in that situation, as it is only for resetting the timeout counter. Though, I guess it could use `saturating_sub` instead.
Change --scrape-examples flag to -Z rustdoc-scrape-examples
I'm working on getting the scrape examples feature working on docs.rs. However, docs.rs uses `cargo rustdoc` instead of `cargo doc`, and right now the `--scrape-examples` flag is only allowed for `cargo doc`. So this PR changes it to a `-Z` flag that can be passed to either command.