-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 :)
- Loading branch information
Showing
2 changed files
with
194 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters