about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-11 08:55:34 +0000
committerbors <bors@rust-lang.org>2024-07-11 08:55:34 +0000
commit45609a995e766d614da694d353f7aee03820b0f9 (patch)
treeb775d54d68b7aa8309c240d9b479458e5c7fec2b /compiler/rustc_codegen_gcc
parent0d6bd91e99ff3b7d367499fc38fc9b9047652901 (diff)
parentd33e96ba008a04796bcd3ae964df04f4ef0bb450 (diff)
downloadrust-45609a995e766d614da694d353f7aee03820b0f9.tar.gz
rust-45609a995e766d614da694d353f7aee03820b0f9.zip
Auto merge of #17571 - winstxnhdw:bool-to-enum-no-dupe, r=Veykril
feat: do not add new enum if it already exists

## 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,

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

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

will be transformed into,

```rs
#[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.
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions