-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust enum variant spans to exclude any explicit discriminant
Fixes 5686 For reference, explicit discriminants were proposed in [RFC-2363]. `ast::Variant` spans extend to include explicit discriminants when they are present. Now we'll adjust the span of enum variants to exclude any explicit discriminant. [RFC-2363]: https://rust-lang.github.io/rfcs/2363-arbitrary-enum-discriminant.html
- Loading branch information
Showing
3 changed files
with
104 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#[repr(u8)] | ||
enum MyEnum { | ||
UnitWithExplicitDiscriminant = 0, | ||
EmptyStructSingleLineBlockComment { | ||
/* Comment */ | ||
} = 1, | ||
EmptyStructMultiLineBlockComment { | ||
/* | ||
* Comment | ||
*/ | ||
} = 2, | ||
EmptyStructLineComment { | ||
// comment | ||
} = 3, | ||
EmptyTupleSingleLineBlockComment( | ||
/* Comment */ | ||
) = 4, | ||
EmptyTupleMultiLineBlockComment( | ||
/* | ||
* Comment | ||
*/ | ||
) = 5, | ||
EmptyTupleLineComment( | ||
// comment | ||
) = 6, | ||
} | ||
|
||
enum Animal { | ||
Dog(/* tuple variant closer in comment -> ) */) = 1, | ||
#[hello(world)] | ||
Cat(/* tuple variant close in leading attribute */) = 2, | ||
Bee(/* tuple variant closer on associated field attribute */ #[hello(world)] usize) = 3, | ||
Fox(/* tuple variant closer on const fn call */) = some_const_fn(), | ||
Ant(/* tuple variant closer on macro call */) = some_macro!(), | ||
Snake {/* stuct variant closer in comment -> } */} = 6, | ||
#[hell{world}] | ||
Cobra {/* struct variant close in leading attribute */} = 6, | ||
Eagle {/* struct variant closer on associated field attribute */ #[hell{world}]value: Sting} = 7, | ||
Koala {/* struct variant closer on macro call */} = some_macro!{} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#[repr(u8)] | ||
enum MyEnum { | ||
UnitWithExplicitDiscriminant = 0, | ||
EmptyStructSingleLineBlockComment {/* Comment */} = 1, | ||
EmptyStructMultiLineBlockComment { | ||
/* | ||
* Comment | ||
*/ | ||
} = 2, | ||
EmptyStructLineComment { | ||
// comment | ||
} = 3, | ||
EmptyTupleSingleLineBlockComment(/* Comment */) = 4, | ||
EmptyTupleMultiLineBlockComment( | ||
/* | ||
* Comment | ||
*/ | ||
) = 5, | ||
EmptyTupleLineComment( | ||
// comment | ||
) = 6, | ||
} | ||
|
||
enum Animal { | ||
Dog(/* tuple variant closer in comment -> ) */) = 1, | ||
#[hello(world)] | ||
Cat(/* tuple variant close in leading attribute */) = 2, | ||
Bee( | ||
/* tuple variant closer on associated field attribute */ #[hello(world)] usize, | ||
) = 3, | ||
Fox(/* tuple variant closer on const fn call */) = some_const_fn(), | ||
Ant(/* tuple variant closer on macro call */) = some_macro!(), | ||
Snake {/* stuct variant closer in comment -> } */} = 6, | ||
#[hell{world}] | ||
Cobra {/* struct variant close in leading attribute */} = 6, | ||
Eagle { | ||
/* struct variant closer on associated field attribute */ | ||
#[hell{world}] | ||
value: Sting, | ||
} = 7, | ||
Koala {/* struct variant closer on macro call */} = some_macro! {}, | ||
} |