-
Notifications
You must be signed in to change notification settings - Fork 84
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
handle numeric fields in struct syntax #949
Conversation
fn field<S: Into<String>>(&mut self, raw_id: S) -> Id { | ||
let raw_id = raw_id.into(); | ||
let f = || raw_id.clone(); | ||
Self::id(&mut self.rename_count, &mut self.field_to_name, IdKind::Field, &raw_id, f) |
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.
Will this store the name in key_to_name
even for numeric fields for which we are not going to use the rename_count
in lifetime_emit
? Does that matter?
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.
Yes
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.
Why is the distinction in lifetime_emit
necessary?
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.
I guess it's not necessary, now that I think about it. I guess the original reason I did it was because I didn't think it made sense to use IdKind::Local for field names.
17528d1
to
3a20c67
Compare
Did you know you can do:
Well, I didn't! I only realized it because rustc's internal de-sugaring of '?' generates code that uses this form. Then I checked, and it turns out users can write it this way too. This PR handles the numeric identifiers correctly (previously, Verus would panic because it didn't translate the to VIR correctly).
VIR previously had this note for struct-syntax patterns and struct-syntax constructors:
The "appear in order" part is no longer true as of this PR. It seems nobody was relying on it, anyway, but it would be good for someone other than me to double-check.