about summary refs log tree commit diff
path: root/tests/rustdoc-js-std/parser-slice-array.js
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-09-29 10:20:11 +0000
committerbors <bors@rust-lang.org>2023-09-29 10:20:11 +0000
commit87e2c310f9f1770aa09c1223ae4a5b7b8ce33360 (patch)
tree01f374eb428456ebe9b5bb5e86c96f5fb8e8e4c7 /tests/rustdoc-js-std/parser-slice-array.js
parentf19479a2ad238ad861cfe8d57e63beeccb56169e (diff)
parent1b3e5b2105b20b3237efaac17c4a9761890f6597 (diff)
downloadrust-87e2c310f9f1770aa09c1223ae4a5b7b8ce33360.tar.gz
rust-87e2c310f9f1770aa09c1223ae4a5b7b8ce33360.zip
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 :)
Diffstat (limited to 'tests/rustdoc-js-std/parser-slice-array.js')
0 files changed, 0 insertions, 0 deletions