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

"Add missing fields" intention with conditional compilation doesn't order fields properly #10824

Open
nazar-pc opened this issue Aug 25, 2023 · 2 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

enum E {
    V0 {
        a: u8,
        #[cfg(feature = "f")]
        b: u8,
        c: u8,
        d: u8,
    },
}

fn foo() {
    let e = E::V0 {
        a: 1,
        #[cfg(feature = "f")]
        b: 1,
        d: 1,
    };
}

In above example use intention on E::V0 to add missing field c. Expectation is that it'll appear after b: 1, but it appears at the end after d: 1.

Interestingly, remove a field in above example and field will be added to the beginning 🤔

Ordering works correctly when no conditional compilation new field appears in correct spot.

P.S. Inspection would be also nice for ordering not matching definition.

@nazar-pc nazar-pc changed the title Add missing fields intention with conditional compilation doesn't order fields properly "Add missing fields" intention with conditional compilation doesn't order fields properly Aug 25, 2023
@Maksim20023
Copy link
Collaborator

Hi! Thank you for reaching us.
This is a known problem, and we already have the same report. Please take a look at #10345. Unfortunately, we don’t have an estimated time to resolve it, and if we have any new information, we will add a reply to that ticket.
If you have any further suggestions, please let us know.

@nazar-pc
Copy link
Author

🤣 it was me who submitted that one and even examples are very similar. Consistency ❗

I'll close the old one since it does seem to work for me now if conditional compilation is not involved.

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

2 participants