fix(run): Help teach about argument escaping#16225
Merged
weihanglo merged 1 commit intorust-lang:masterfrom Nov 7, 2025
Merged
fix(run): Help teach about argument escaping#16225weihanglo merged 1 commit intorust-lang:masterfrom
weihanglo merged 1 commit intorust-lang:masterfrom
Conversation
It is not obvious that how to escape arguments to be forwarded literally to an underlying program, like `--help`. `cargo test` has a message: ``` Run `cargo test -- --help` for test binary options. ``` Mirroring that exactly in `cargo run` isn't appropriate because we'd be saying there is `--help` when there might not be. Instead, I took inspiration from clap's error message: ```console $ cargo test --gfdfgdf error: unexpected argument '--gfdfgdf' found tip: to pass '--gfdfgdf' as a value, use '-- --gfdfgdf' Usage: cargo test [OPTIONS] [TESTNAME] [-- [ARGS]...] For more information, try '--help'. ``` I checked `cargo rustc` and `cargo rustdoc` to see if they could be helped like this but they will return errors about needing to specify the specific binary, so they are a little more complicated. Fixes rust-lang#9707
Collaborator
weihanglo
approved these changes
Nov 7, 2025
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Nov 12, 2025
Update cargo 10 commits in 445fe4a68f469bf936b2fd81de2c503b233a7f4f..2d4fa139552ebdd5f091a1401ed03f7dc62cb43f 2025-11-07 18:08:19 +0000 to 2025-11-12 15:56:06 +0000 - feat: Add unstable rustc-unicode flag (rust-lang/cargo#16243) - fix(package): all tar entries timestamp be the same (rust-lang/cargo#16242) - feat: emit help messages for github pull request url in dependency (rust-lang/cargo#16207) - docs: fix comments for alternative registry fns (rust-lang/cargo#16235) - add into_value utility function for inheritableField (rust-lang/cargo#16234) - fix(command-vendor): strip_prefix panic in cp_sources method (rust-lang/cargo#16214) - fix(lock): Be moore direct in the error message (rust-lang/cargo#16233) - fix(lock): In error, differentiate between creating and updating lockfile (rust-lang/cargo#16227) - fix(cli): Refer to commands, not subcommands (rust-lang/cargo#16226) - fix(run): Help teach about argument escaping (rust-lang/cargo#16225)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
It is not obvious that how to escape arguments to be forwarded literally to an underlying program, like
--help.cargo testhas a message:Mirroring that exactly in
cargo runisn't appropriate because we'd be saying there is--helpwhen there might not be.Instead, I took inspiration from clap's error message:
I checked
cargo rustcandcargo rustdocto see if they could be helped like this but they will return errors about needing to specify the specific binary, so they are a little more complicated.Fixes #9707
How to test and review this PR?