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

feat: do not add new enum if it already exists #17571

Merged
merged 3 commits into from
Jul 11, 2024
Merged

feat: do not add new enum if it already exists #17571

merged 3 commits into from
Jul 11, 2024

Conversation

winstxnhdw
Copy link
Contributor

@winstxnhdw winstxnhdw commented Jul 9, 2024

Summary

This PR introduces a check for the existence of another enum within the current scope, and if it exist, we skip add_enum_def.

Why?

Currently, when using the bool_to_enum assist more than once, it is possible to add multiple enum definitions. For example, the following snippet,

#[derive(PartialEq, Eq)]
enum Bool {
    True,
    False,
}

fn main() {
    let a = Bool::True;
    let b = true;
    println!("Hello, world!");
}

will be transformed into,

#[derive(PartialEq, Eq)]
enum Bool {
    True,
    False,
}

#[derive(PartialEq, Eq)]
enum Bool {
    True,
    False,
}

fn main() {
    let a = Bool::True;
    let b = Bool::True;
    println!("Hello, world!");
}

This can be annoying for users to clean up.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 9, 2024
- unrelated to the PR but I wanted to change this in #17467
@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 10, 2024
@Veykril
Copy link
Member

Veykril commented Jul 11, 2024

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Jul 11, 2024

📌 Commit c4bcec2 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 11, 2024

⌛ Testing commit c4bcec2 with merge 5577e4e...

@bors
Copy link
Contributor

bors commented Jul 11, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 5577e4e to master...

@bors bors merged commit 5577e4e into rust-lang:master Jul 11, 2024
11 checks passed
@winstxnhdw winstxnhdw deleted the bool-to-enum-no-dupe branch July 21, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants