Parse & reject postfix operators after casts by daboross · Pull Request #68985 · rust-lang/rust (original) (raw)
Makes sense that we want to make it more reliable- we've added in address hashing, or at least what I think is good address hashing.
As for expr :/as Type1 :/as Type2
, I've added tests, but they don't fail. Looking at how this behaves prior to these changes, I don't think these are expected to fail? x as T1 as T2
is valid today. This doesn't change that, it'll still just parse x as T1
, then fail to see any postfix, then go back up to parse_assoc_expr
and parse the second as T2
(or : T2
).
Given that we test the expr pointer hash now, if parse_dot_or_call_expr_with_
ever changes to start parsing type ascriptions or casts, then these tests should start to fail because we'll trigger our error message. I think this is OK?
The failures come from not anticipating that this function is also used for type ascriptions (as noted by @petrochenkov), e.g. foo: Vec. (See the function right below this one for how that happens.)
We've gone through and fixed this, I think.