-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Syntax of rustc --cfg with key and value is obscure. #66450
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Activity
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-frontendArea: Compiler frontend (errors, parsing and HIR)Area: Compiler frontend (errors, parsing and HIR)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Hi,
I was recently defeated by
rustc --cfg.rustc -hsays:Hrm, well I know that stuff like
--cfg varshould work, but that I should also be able to assign a value:Eh? I passed exactly what the error asked. And obviously the backticks can't form the solution, as they'd open a sub-shell.
The solution is to use:
rustc --cfg 'key="val"'The quoting is very specific.
Swapping the single and double quotes won't work:
And oddly, quoting the value is ok, but not the key:
I find this wholly unexpected and I had to grep the source code to find out how to use the argument :(
So are the current limitations of the interface intentional?
If so, we should improve the
-hdoc and error message.If not, what do we want? Should
--cfgaccept:key=val'key="val""key='val'"'"key"="val"'"key=val"Thanks.