Add error for trailing angle brackets. by davidtwco · Pull Request #57817 · rust-lang/rust (original) (raw)
This commit extends the trailing >
detection to also work for paths
such as Foo::<Bar>>:Baz
.
This involves making the existing check take the token that is expected to follow the path being checked as a parameter.
Care is taken to ensure that this only happens on the construction of a whole path segment and not a partial path segment (during recursion).
Through this enhancement, it was also observed that the ordering of right shift token and greater than tokens was overfitted to the examples being tested.
In practice, given a sequence of >
characters: >>>>>>>>>
..then they will be split into >>
eagerly: >> >> >> >> >
.
..but when a <
is prepended, then the first >>
is split:
<T> > >> >> >> >
..and then when another <
is prepended, a right shift is first again:
Vec<<T>> >> >> >> >
In the previous commits, a example that had two <<
characters was
always used and therefore it was incorrectly assumed that >>
would
always be first - but when there is a single <
, this is not the case.