87e2c310f9
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 :) |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |