-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust enum variant spans to exclude any explicit discriminant #5687
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}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol 🔥
Fixes #5686
For reference, explicit discriminants were proposed in RFC-2363, and I believe the feature is stabilized.
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.