rust/tests/source/issue_5686.rs
Yacin Tmimi 2c30fa5a82 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
2023-06-19 10:12:19 -05:00

41 lines
1.2 KiB
Rust

#[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!{}
}