-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax of rustc --cfg
with key and value is obscure.
#66450
Comments
It is It may be difficult to provide a general suggestion as different environments will need different escaping. It could maybe include a hint to check that it the value is properly escaped for whatever environment you are in, but I'm not sure if that would be helpful. FWIW, the documentation does include some examples, but they don't work in powershell, for example. |
Hi, I'm also struggling a little with this syntax and was wondering if I am misunderstanding how to use the config file in the .cargo folder. I am trying to go from this Why? Because that is the feature I want to use for the project I am working on and don't want to have to pass it to the command line every time. The only way I can achieve this right now is to set the following in my Cargo.toml file:
However, this doesn't seem right to me and I want to see if the same feature could be defaulted in my
Cargo accepts this but seems to ignore it unfortunately. A call to PS. If anyone else comes across this and wants to know more about cargo features (can be difficult to search for) and cargo configuration this a good place to start: |
@ninjasource Placing that in a config, it seems to work for me (I see |
Using an alias in my .cargo/config file worked very well, thanks!
And then
So I guess calling |
…ror-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 rust-lang#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`
If it doesn't support dashes, it would also be nice if it just said so :)
|
Hi,
I was recently defeated by
rustc --cfg
.rustc -h
says:Hrm, well I know that stuff like
--cfg var
should 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
-h
doc and error message.If not, what do we want? Should
--cfg
accept:key=val
'key="val"
"key='val'"
'"key"="val"'
"key=val"
Thanks.
The text was updated successfully, but these errors were encountered: