-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Get structured cargo config info #9342
Comments
CC @ehuss |
Sorry, I'm a bit confused about the discussion of config files and how that relates to target On nightly, you can use |
Sorry if the question was not clear. We want to support cases when a project is supposed to be built with a non-host target.
Yeah and it actually takes into account cargo config. But unfortunately, this command requires you to pass the concrete target if there are several ones and compiles it. The latest thing makes this option unusable for us because it may require a lot of time and may fail because of different reasons. |
That command shouldn't trigger a compile. It should print something like the following and exit immediately. Are you not seeing that?
|
Oh, looks awesome! Some questions about the feature itself:
|
It is a part of 1.52, but is unstable so should only be used on nightly. No particular plans right now. I opened #9357 for more discussion. |
@ehuss Thank you! |
7093: CARGO: fetch cfg options according to Cargo config r=vlad20012 a=Undin Now the plugin use `cargo rustc --print cfg` instead of raw `rustc --print cfg` that allows taking [Cargo config](https://doc.rust-lang.org/cargo/reference/config.html) into account, i.e. fetch cfg options for custom build target, `RUSTFLAGS`, etc. As a result, evaluation of `cfg` attributes also takes such custom options into account and users can set up them. Note, `cargo rustc --print cfg` option is available only since Rust 1.52. With older toolchain, the plugin uses host `cfg` options Fixes #5183 Part of #6104 Related to rust-lang/cargo#9342 <img width="358" src="https://user-images.githubusercontent.com/2539310/114613416-fba27200-9cab-11eb-9b41-97457858ec54.png"/> <img width="358" alt="Screen Shot 2021-04-12 at 15 12 51" src="https://user-images.githubusercontent.com/2539310/114392523-95312d00-9ba1-11eb-849a-827bae53f69a.png"> changelog: Now the plugin takes [Cargo config](https://doc.rust-lang.org/cargo/reference/config.html) into account during evaluation of `cfg` conditions. Note, it works since Rust 1.52.0 Co-authored-by: Arseniy Pendryak <[email protected]>
I want to get
target
info defined in cargo config to improve IDE support (in my case it's about IntelliJ Rust plugin but I suppose it may be useful for any IDE integration). More precisely, I want to fetch correct info about cfg options from the compiler if a user uses some specific target to compiler the project to provide the corresponding highlighting, name resolution and other code insight features that may depend on cfg options. For example, see intellij-rust/intellij-rust#5183.According to https://doc.rust-lang.org/cargo/reference/config.html, config file may be placed not only in project dir but also in parent directories. Moreover, some specific options can be overridden by environment variables. And all this logic is already implemented in cargo and will be updated in the future if rules about config files are changed.
So, question: is there a way to get structured output about cargo config from cargo (or at least, info about target) not to re-implement described logic in the plugin?
If it's not possible for now, what's the best place for it? A separate command (something like
cargo config
),cargo metadata
or anything else?The text was updated successfully, but these errors were encountered: