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

"Import" should add import with the same conditional compilation as the place it is used #10825

Open
nazar-pc opened this issue Aug 25, 2023 · 0 comments

Comments

@nazar-pc
Copy link

Environment

  • IntelliJ Rust plugin version: 0.4.200.5446-232-nightly
  • Rust toolchain version: 1.73.0-nightly (1b198b3a1 2023-08-13) x86_64-unknown-linux-gnu
  • IDE name and version: IntelliJ IDEA 2023.2.1 Ultimate Edition (IU-232.9559.62)
  • Operating system: Linux 6.4.8-x64v4-xanmod1
  • Macro expansion: enabled
  • Additional experimental features: org.rust.macros.proc.attr, org.rust.cargo.emulate.terminal, org.rust.macros.proc

Problem description

Steps to reproduce

struct S {
    #[cfg(feature = "f")]
    n: NonZeroU8,
}

Both when authoring the struct and manually invoking "Import" intention it adds following import:

use std::num::NonZeroU8;

While this would be much more convenient and more likely what developer intends to do:

#[cfg(feature = "f")]
use std::num::NonZeroU8;

This is especially annoying when multiple imports are combined together and developer needs to manually remove it from one group and place into (or create) conditionally-compiled group of imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant