bors 87e2c310f9 Auto merge of #15667 - rmehri01:bool_to_enum_top_level, r=Veykril
fix: make bool_to_enum assist create enum at top-level

This pr makes the `bool_to_enum` assist create the `enum` at the next closest module block or at top-level, which fixes a few tricky cases such as with an associated `const` in a trait or module:

```rust
trait Foo {
    const $0BOOL: bool;
}

impl Foo for usize {
    const BOOL: bool = true;
}

fn main() {
    if <usize as Foo>::BOOL {
        println!("foo");
    }
}
```

Which now properly produces:

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

trait Foo {
    const BOOL: Bool;
}

impl Foo for usize {
    const BOOL: Bool = Bool::True;
}

fn main() {
    if <usize as Foo>::BOOL == Bool::True {
        println!("foo");
    }
}
```

I also think it's a bit nicer, especially for local variables, but didn't really know to do it in the first PR :)
2023-09-29 10:20:11 +00:00
..
2023-09-24 22:47:29 +02:00
2023-09-08 10:49:15 +02:00
2023-09-20 23:02:52 +09:00
2023-09-28 13:16:11 +02:00
2023-09-24 23:45:36 +03:30
2023-09-23 19:43:19 -03:00
2023-09-24 22:47:29 +02:00
2023-09-15 16:43:21 +09:00
2023-09-22 10:13:51 +02:00
2023-09-26 12:25:59 +02:00
2023-09-24 23:45:36 +03:30
2023-09-02 18:28:36 +03:00
2023-09-04 18:00:12 +02:00