Skip to content
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

Activate features of individual crates in a cargo workspace #10298

Open
Lucretiel opened this issue Sep 20, 2021 · 6 comments
Open

Activate features of individual crates in a cargo workspace #10298

Lucretiel opened this issue Sep 20, 2021 · 6 comments
Labels
C-feature Category: feature request E-unknown It's unclear if the issue is E-hard or E-easy without digging in

Comments

@Lucretiel
Copy link

Currently, the only two options for cargo features in rust-analyzer are "all features" and "list of features". If you're in a cargo workspace, the "list of features" seems to apply to all crates, which breaks certain workflows when working in those crates (in particular, the "▷Run Test" inline buttons). There should be a way to apply designate specific crates to apply features in the project settings.

@ia0
Copy link

ia0 commented Mar 17, 2022

Note that there's the same issue with cargo.noDefaultFeatures which doesn't work in a cargo workspace.

@flodiebold flodiebold added E-unknown It's unclear if the issue is E-hard or E-easy without digging in C-feature Category: feature request labels Mar 17, 2022
@shadeglare
Copy link

As I understand the CLion Rust plugin has a similar ability. You can activate certain features in a crate during development.
Even if you make a reference to the crate in another crate the with different feature flags you edit the crate with the IDE pinned features of your choice.
Screenshot 2022-07-31 at 13 14 52

@dhedey
Copy link

dhedey commented Mar 18, 2023

Related to #8521

This is a big problem for us - we have a few mutually incompatible features (for relatively legitimate reasons) -- and a workspace with many crates with different features. But enabling any feature with eg:

    "rust-analyzer.cargo.features": [
        "serde",
    ],

Works fine when running analysis over the whole workspace*, but errors when running tests under a particular project which doesn't support that flag. As a workaround, you can add an empty dummy feature to each individual cargo project, but it's not ideal.

(*) this is not strictly true - using rust-analyzer.linkedProjects, each individual project needs to have that feature.

The following would all be sufficient fixes to serve our needs :) - in, I'm guessing, increasing order of work:

  • Automatically use the requested rust-analyzer.cargo.features features only for projects / workspaces / crates where they are available / wouldn't error.
  • Allow us to choose features by Cargo.toml file in rust-analyzer.cargo.features or some new config - ie allow a mapping of Cargo.toml paths to features
  • Allow us to choose features through the UI like in CLion

@Veykril
Copy link
Member

Veykril commented May 26, 2023

#14910 addresses this for single workspace projects. Multi workspaces still suffer here

@Lucretiel
Copy link
Author

#14910 addresses this for single workspace projects. Multi workspaces still suffer here

Does it? That just prevents feature abc from being enabled in crates that don't have it; it doesn't provide any way to enable abc in some crates but not others.

@Veykril
Copy link
Member

Veykril commented May 26, 2023

which breaks certain workflows when working in those crates (in particular, the "▷Run Test" inline buttons)

It fixes this scenario, I didn't realize the overall ask was for per crate feature toggles apologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature request E-unknown It's unclear if the issue is E-hard or E-easy without digging in
Projects
None yet
Development

No branches or pull requests

6 participants