-
Notifications
You must be signed in to change notification settings - Fork 380
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
Support cfg features generated by build scripts #4631
Comments
This issue is caused by the fact that The declarations of #[cfg(has_std)]
pub struct IndexMap<K, V, S = RandomState> { ... }
#[cfg(not(has_std))]
pub struct IndexMap<K, V, S> { ... } Currently, IntelliJ Rust only supports some standard cfg options (for more information #4488), so |
4734: CARGO: support items generated by build scripts r=vlad20012 a=Undin While compilation, crate's [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) can generate some new code, `cfg` attributes, environment variables and so on. These changes are the first attempt to support them. What these changes do: * collect info about executed build scripts while refresh. Under the hood, it uses `cargo check` so it can take much more time to get info about project * use generated `cfg` options while `cfg` attribute evaluation. Should fix #4631 * use generated environment variables for path evaluation in include macro calls * extend include macro support. Now, the plugin can process calls without filename in string literals like `include!(env!("BINDINGS"))`. Should make possible to force intelliSence work for `web-sys` (see #3066) * Since recent nightly builds of cargo, it makes possible to turn on full support of `include` macro without using `cargo build --build-plan` and avoid issue about full project recompilation Note, it is under experimental feature and disabled by default. To try it just enabled `org.rust.cargo.evaluate.build.scripts` in `Help | Find Action | Experimental Features` dialog Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
4734: CARGO: support items generated by build scripts r=vlad20012 a=Undin While compilation, crate's [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) can generate some new code, `cfg` attributes, environment variables and so on. These changes are the first attempt to support them. What these changes do: * collect info about executed build scripts while refresh. Under the hood, it uses `cargo check` so it can take much more time to get info about project * use generated `cfg` options while `cfg` attribute evaluation. Should fix #4631 * use generated environment variables for path evaluation in include macro calls * extend include macro support. Now, the plugin can process calls without filename in string literals like `include!(env!("BINDINGS"))`. Should make possible to force intelliSence work for `web-sys` (see #3066) * Since recent nightly builds of cargo, it makes possible to turn on full support of `include` macro without using `cargo build --build-plan` and avoid issue about full project recompilation Note, it is under experimental feature and disabled by default. To try it just enabled `org.rust.cargo.evaluate.build.scripts` in `Help | Find Action | Experimental Features` dialog Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
4734: CARGO: support items generated by build scripts r=vlad20012 a=Undin While compilation, crate's [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) can generate some new code, `cfg` attributes, environment variables and so on. These changes are the first attempt to support them. What these changes do: * collect info about executed build scripts while refresh. Under the hood, it uses `cargo check` so it can take much more time to get info about project * use generated `cfg` options while `cfg` attribute evaluation. Should fix #4631 * use generated environment variables for path evaluation in include macro calls * extend include macro support. Now, the plugin can process calls without filename in string literals like `include!(env!("BINDINGS"))`. Should make possible to force intelliSence work for `web-sys` (see #3066) * Since recent nightly builds of cargo, it makes possible to turn on full support of `include` macro without using `cargo build --build-plan` and avoid issue about full project recompilation Note, it is under experimental feature and disabled by default. To try it just enabled `org.rust.cargo.evaluate.build.scripts` in `Help | Find Action | Experimental Features` dialog Co-authored-by: Arseniy Pendryak <a.pendryak@yandex.ru>
Now there is a way to collect info about generated items including generated cfg option while project refresh action. Under the hood, it uses |
I don't think it should be closed until the corresponding feature is disabled by default |
@vlad20012 902942a removed |
@MSxDOS, please, try the nightly IntelliJ Rust plugin (see instructions), #5186 is included there |
@vlad20012 All good now, thank you. |
I've had no luck getting IndexMap to work even after switching on the experimental Anything we can do to work around or help resolve this issue? For what it's worth, the versions I am using are: IntelliJ Rust plugin version: 0.4.147.3871-211, Rust toolchain version: 1.51.0 stable, IDE name and version: Clion 2021.1.2, Operating system: Ubutu 20.10 and the version of indexmap is v1.6.2. |
@aschmolck Could you provide code where the plugin doesn't work, please? I've tried something very simple like use indexmap::IndexMap;
fn main() {
let map = IndexMap::<i32, i32>::new();
let option = map.get(&1);
} and it works, i.e. types are inferred and methods are suggested |
@Undin thanks, so it appears something in addition to plain indexmap usage is needed to trigger the problem -- I will try to boil it down to a small self-contained example where completion breaks. Is the above with the default IDE config, or did you enable |
I enabled |
No change since then, still broken for |
For what it's worth, although org.rust.cargo.evaluate.build.scripts didn't originally resolve my problem, in current versions of clion it works fine for me (crates like indexmap that use conditionally compilation in some of the signatures now have correct autocompletion after enabling the flag). |
In case it is helpful for others, this worked for me in the 2022.2 version of IntelliJ Community as well. |
Environment
Problem description
Ctrl-clicking function in specific circumstance takes me to wrong function. Experimental macro expansion engine is enabled.
Steps to reproduce
Cargo.toml:
main.rs:
IndexMap::new
is highlighted as error with "Unresolved reference: `new`".Ctrl-clicking IndexMap, despite being highlighted red, correctly takes me to its declaration.
Ctrl-clicking
new
incorrectly takes me to thenew
function insideimpl<D: Input + FixedOutput + Reset + Clone + Default> Digest for D
, part of thedigest
crate.Compilation works and gives no warnings or errors.
The text was updated successfully, but these errors were encountered: