fix: fix "parser seems stuck" panic when parsing colossal files by jon...
source link: https://github.com/rust-lang/rust-analyzer/pull/13794
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.
Conversation
The parser step count is incremented every time the parser inspects a token. It's purpose is to ensure the parser doesn't get stuck in infinite loops. But since self.pos
grows monotonically when parsing source code, it gives a better idea for whether the parser is stuck or not: if self.pos
is changed, we know that the parser cannot be stuck, so it is safe to reset the step count to 0. This makes the limit check scale with the size of the file, and so should fix #13788.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK