@@ -674,47 +674,21 @@ impl<'a> Parser<'a> {
674
674
675
675
/// Attempt to consume a `<`. If `<<` is seen, replace it with a single
676
676
/// `<` and continue. If a `<` is not seen, return false.
677
- ///
678
- /// This is meant to be used when parsing generics on a path to get the
679
- /// starting token. The `force` parameter is used to forcefully break up a
680
- /// `<<` token. If `force` is false, then `<<` is only broken when a lifetime
681
- /// shows up next. For example, consider the expression:
682
- ///
683
- /// foo as bar << test
684
- ///
685
- /// The parser needs to know if `bar <<` is the start of a generic path or if
686
- /// it's a left-shift token. If `test` were a lifetime, then it's impossible
687
- /// for the token to be a left-shift, but if it's not a lifetime, then it's
688
- /// considered a left-shift.
689
- ///
690
- /// The reason for this is that the only current ambiguity with `<<` is when
691
- /// parsing closure types:
692
- ///
693
- /// foo::<<'a> ||>();
694
- /// impl Foo<<'a> ||>() { ... }
695
- fn eat_lt ( & mut self , force : bool ) -> bool {
677
+ fn eat_lt ( & mut self ) -> bool {
696
678
match self . token {
697
679
token:: Lt => { self . bump ( ) ; true }
698
680
token:: BinOp ( token:: Shl ) => {
699
- let next_lifetime = self . look_ahead ( 1 , |t| match * t {
700
- token:: Lifetime ( ..) => true ,
701
- _ => false ,
702
- } ) ;
703
- if force || next_lifetime {
704
- let span = self . span ;
705
- let lo = span. lo + BytePos ( 1 ) ;
706
- self . replace_token ( token:: Lt , lo, span. hi ) ;
707
- true
708
- } else {
709
- false
710
- }
681
+ let span = self . span ;
682
+ let lo = span. lo + BytePos ( 1 ) ;
683
+ self . replace_token ( token:: Lt , lo, span. hi ) ;
684
+ true
711
685
}
712
686
_ => false ,
713
687
}
714
688
}
715
689
716
690
fn expect_lt ( & mut self ) {
717
- if !self . eat_lt ( true ) {
691
+ if !self . eat_lt ( ) {
718
692
let found_token = self . this_token_to_string ( ) ;
719
693
let token_str = Parser :: token_to_string ( & token:: Lt ) ;
720
694
self . fatal ( format ! ( "expected `{}`, found `{}`" ,
@@ -1877,7 +1851,7 @@ impl<'a> Parser<'a> {
1877
1851
let identifier = self . parse_ident ( ) ;
1878
1852
1879
1853
// Parse types, optionally.
1880
- let parameters = if self . eat_lt ( false ) {
1854
+ let parameters = if self . eat_lt ( ) {
1881
1855
let ( lifetimes, types, bindings) = self . parse_generic_values_after_lt ( ) ;
1882
1856
1883
1857
ast:: AngleBracketedParameters ( ast:: AngleBracketedParameterData {
@@ -1938,7 +1912,7 @@ impl<'a> Parser<'a> {
1938
1912
}
1939
1913
1940
1914
// Check for a type segment.
1941
- if self . eat_lt ( false ) {
1915
+ if self . eat_lt ( ) {
1942
1916
// Consumed `a::b::<`, go look for types
1943
1917
let ( lifetimes, types, bindings) = self . parse_generic_values_after_lt ( ) ;
1944
1918
segments. push ( ast:: PathSegment {
0 commit comments