syntax: Tweak path parsing logic#37290
Conversation
jseyfried
left a comment
There was a problem hiding this comment.
Nice! r=me modulo union!();
src/libsyntax/parse/parser.rs
Outdated
There was a problem hiding this comment.
nit: I believe this can be slightly simplified to
(LOOKAHEAD_BUFFER_CAPACITY + self.end - self.start) % LOOKAHEAD_BUFFER_CAPACITYThere was a problem hiding this comment.
Yep, looks simpler.
src/libsyntax/parse/parser.rs
Outdated
There was a problem hiding this comment.
Is there a reason this is 8? I think 6 would suffice.
There was a problem hiding this comment.
x % LOOKAHEAD_BUFFER_CAPACITY is faster.
Not much difference either way, though.
There was a problem hiding this comment.
Good point -- I forgot about peephole optimizations.
src/libsyntax/parse/parser.rs
Outdated
There was a problem hiding this comment.
I think this would break the macro invocation union!(); in an item position.
There was a problem hiding this comment.
Hmm, right, will fix.
|
@bors r=jseyfried |
|
📌 Commit fea630e has been approved by |
syntax: Tweak path parsing logic Associated paths starting with `<<` are parsed in patterns. Paths like `self::foo::bar` are interpreted as paths and not as `self` arguments in methods (cc @matklad). Now, I believe, *all* paths are consistently parsed greedily in case of ambiguity. Detection of `&'a mut self::` requires pretty large (but still fixed) lookahead, so I had to increase the size of parser's lookahead buffer. Curiously, if `lookahead_distance >= lookahead_buffer_size` was used previously, the parser hung forever, I fixed this as well, now it ICEs. r? @jseyfried
add test for rust-lang#37765 Adds a test for rust-lang#37765, a path parsing fix which removes the need for a parenthesis workaround. Closes rust-lang#37765. cc rust-lang#37290 @withoutboats r? @petrochenkov
add test for rust-lang#37765 Adds a test for rust-lang#37765, a path parsing fix which removes the need for a parenthesis workaround. Closes rust-lang#37765. cc rust-lang#37290 @withoutboats r? @petrochenkov
Associated paths starting with
<<are parsed in patterns.Paths like
self::foo::barare interpreted as paths and not asselfarguments in methods (cc @matklad).Now, I believe, all paths are consistently parsed greedily in case of ambiguity.
Detection of
&'a mut self::requires pretty large (but still fixed) lookahead, so I had to increase the size of parser's lookahead buffer.Curiously, if
lookahead_distance >= lookahead_buffer_sizewas used previously, the parser hung forever, I fixed this as well, now it ICEs.r? @jseyfried