Properly handle postfix inc/dec in standalone and subexpr scenarios by chenyukan...
source link: https://github.com/rust-lang/rust/pull/104875
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
let prev_is_semi = { |
||
if let Ok(prev_code) = self.sess.source_map().span_to_prev_source(lhs.span) && |
||
prev_code.trim_end().ends_with(";") { |
||
true |
||
} else { |
||
false |
||
} |
||
}; |
Contributor
estebank Nov 25, 2022
This is a bit of a hack, but fair given where it lives. I would like to do a perf run of an alternative approach: modify lhs
to hold a starts_statement: bool
field. I think that it might hit memory a bit, but that would be far less brittle to refactors breaking this heuristic. Would you have time to try doing that as part of this PR?
Contributor
Author
chenyukang Nov 26, 2022
You means add a field with boolean type to LhsExpr
type?
Contributor
Author
chenyukang Nov 26, 2022
Updated the code.
I don't think there is a perf regerssion here, we are at error report codepath,
but you may have a double-check.
Contributor
Author
chenyukang Nov 26, 2022
Yes, maybe cost a little bit more memory.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK