Adjust enum variant spans to exclude any explicit discriminant#5687
Adjust enum variant spans to exclude any explicit discriminant#5687calebcartwright merged 1 commit intorust-lang:masterfrom
Conversation
|
Would suggest including the search needle in a few other pathological positions, e.g. within a comment or an attribute (assuming the latter is at least parseable, even if invalid syntactically), to make sure that |
|
Just want to make sure I'm understanding you correctly. Are you referring to a scenario like this: enum Animal {
// Closing tuple struct needle --------|
// v
Dog(/* Coment with closing parenthesis ) */) = 1,
Cat(/* Coment with */ #[hello(world)] String) = 2,
// ^
// Closing tuple struct needle ----|
} |
Yup exactly, anywhere some sneaky needles could reside in a parseable position |
e0f9ec9 to
04623fb
Compare
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
|
@calebcartwright I made some updates to the PR. A combination of shrinking the |
| 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}] |
Fixes #5686
For reference, explicit discriminants were proposed in RFC-2363, and I believe the feature is stabilized.
ast::Variantspans extend to include explicit discriminants when they are present.Now we'll adjust the span of enum variants to exclude any explicit discriminant.