diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-21 22:03:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-21 22:03:14 +0100 |
| commit | e38cbc78aa18354a8b4e1477cd090bd83c298ced (patch) | |
| tree | e7af78ff9601cdcba2bd921c36afe4ee4f7a1f7c /src | |
| parent | 701a8330e8ee2135137fa3fed5154e5d03945df9 (diff) | |
| parent | af87248037a8c86f580c469ce7d2a10c0b12f2fd (diff) | |
| download | rust-e38cbc78aa18354a8b4e1477cd090bd83c298ced.tar.gz rust-e38cbc78aa18354a8b4e1477cd090bd83c298ced.zip | |
Rollup merge of #92835 - iwanders:issue-66450-improve-cfg-error-message, r=nagisa
Improve error message for key="value" cfg arguments. Hi, I ran into difficulties using the `--cfg` flag syntax, first hit when googling for the error was issue https://github.com/rust-lang/rust/issues/66450. Reading that issue, it sounded like the best way to improve the experience was to improve the error message, this is low risk and doesn't introduce any additional argument parsing. The issue mentions that it is entirely dependent on the shell, while this may be true, I think guiding the the user into the realization that the quotes may need to be escaped is helpful. The two suggested escapings both work in Bash and in the Windows command prompt. fyi `@ehuss`
Diffstat (limited to 'src')
4 files changed, 8 insertions, 2 deletions
diff --git a/src/test/ui/conditional-compilation/cfg-arg-invalid-1.rs b/src/test/ui/conditional-compilation/cfg-arg-invalid-1.rs index 36dd78dd2b1..d20e79b9db3 100644 --- a/src/test/ui/conditional-compilation/cfg-arg-invalid-1.rs +++ b/src/test/ui/conditional-compilation/cfg-arg-invalid-1.rs @@ -1,3 +1,3 @@ // compile-flags: --cfg a(b=c) -// error-pattern: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`) +// error-pattern: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\") fn main() {} diff --git a/src/test/ui/conditional-compilation/cfg-arg-invalid-1.stderr b/src/test/ui/conditional-compilation/cfg-arg-invalid-1.stderr index 1e7922a9ff1..3a12e978680 100644 --- a/src/test/ui/conditional-compilation/cfg-arg-invalid-1.stderr +++ b/src/test/ui/conditional-compilation/cfg-arg-invalid-1.stderr @@ -1,2 +1,2 @@ -error: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`) +error: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\") diff --git a/src/test/ui/conditional-compilation/cfg-arg-invalid-9.rs b/src/test/ui/conditional-compilation/cfg-arg-invalid-9.rs new file mode 100644 index 00000000000..628b335c873 --- /dev/null +++ b/src/test/ui/conditional-compilation/cfg-arg-invalid-9.rs @@ -0,0 +1,4 @@ +// Test for missing quotes around value, issue #66450. +// compile-flags: --cfg key=value +// error-pattern: invalid `--cfg` argument: `key=value` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\") +fn main() {} diff --git a/src/test/ui/conditional-compilation/cfg-arg-invalid-9.stderr b/src/test/ui/conditional-compilation/cfg-arg-invalid-9.stderr new file mode 100644 index 00000000000..985b5252258 --- /dev/null +++ b/src/test/ui/conditional-compilation/cfg-arg-invalid-9.stderr @@ -0,0 +1,2 @@ +error: invalid `--cfg` argument: `key=value` (expected `key` or `key="value"`, ensure escaping is appropriate for your shell, try 'key="value"' or key=\"value\") + |
