-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Replace pointer address checks in the parser #103700
Replace pointer address checks in the parser #103700
Conversation
The parser used to check the address of the `P<Expr>` to determine whether a method it called had changed the value. This is undesirable for serveral reasons: - The `P::map` function allows changes while still maintaining address stability, which could break this code (although it isn't a problem right now) - Replacing it with a boolean flag is really simple - This is a Rust parser and I don't like casting pointers to integers in my Rust parser - I really dont.
ca624b1
to
1a043b2
Compare
&mut self, | ||
mut e: P<Expr>, | ||
lo: Span, | ||
) -> PResult<'a, (P<Expr>, bool)> { |
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.
maybe a (doc) comment describing what this bool means would be nice,,
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.
galaxy brain: enum ParseDotOrCall { Changed(P<Expr>), Unchanged(P<Expr>) }
😅
but a bool is fine.
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.
enum ParseDotOrCall {
Changed(P<Expr>),
Unchanged(P<Expr>),
CheckTheAddressJustToBeSure(P<Expr>),
}
Just being extra defensive, this maybe could use a perf run... But I will @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 1a043b2 with merge 75b17f6d708e321f05dd86ccae511d29ff954d97... |
anyways r=me once this perf run comes back clean, if it doesn't then i'll give a look at the results. @bors delegate+ |
✌️ @Nilstrieb can now approve this pull request |
@@ -998,13 +999,14 @@ impl<'a> Parser<'a> { | |||
continue; |
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.
You forgot a changed_expr
on the previous line.
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.
Add the corresponding UI test please:
fn main() {
(1,) as (i32,) .0
//~^ ERROR cast cannot be followed by a field access
}
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.
Actually, I feel like changed
is redundant with the check on line 836:
if !matches!(with_postfix.kind, ExprKind::Cast(_, _) | ExprKind::Type(_, _)) || changed {
Why did we need changed
in the first place??
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.
Status update, as far as I can tell: we don't
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 like this
@bors delegate- |
☀️ Try build successful - checks-actions |
Queued 75b17f6d708e321f05dd86ccae511d29ff954d97 with parent 77e7b74, future comparison URL. |
Finished benchmarking commit (75b17f6d708e321f05dd86ccae511d29ff954d97): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
(probably noise) |
I forgot about one location the body and it turns out this location is very nested and non-trivial. I'm sure it can be fixed, but that's too much effort for me right. If anyone wants to pick it up, feel free. |
The parser used to check the address of the
P<Expr>
to determine whether a method it called had changed the value. This is undesirable for serveral reasons:P::map
function allows changes while still maintaining address stability, which could break this code (although it isn't a problem right now)r? @compiler-errors because he told me to fix it after i made fun of it