@@ -669,45 +669,22 @@ impl<'a> Parser<'a> {
669
669
/// `<` and continue. If a `<` is not seen, return false.
670
670
///
671
671
/// This is meant to be used when parsing generics on a path to get the
672
- /// starting token. The `force` parameter is used to forcefully break up a
673
- /// `<<` token. If `force` is false, then `<<` is only broken when a lifetime
674
- /// shows up next. For example, consider the expression:
675
- ///
676
- /// foo as bar << test
677
- ///
678
- /// The parser needs to know if `bar <<` is the start of a generic path or if
679
- /// it's a left-shift token. If `test` were a lifetime, then it's impossible
680
- /// for the token to be a left-shift, but if it's not a lifetime, then it's
681
- /// considered a left-shift.
682
- ///
683
- /// The reason for this is that the only current ambiguity with `<<` is when
684
- /// parsing closure types:
685
- ///
686
- /// foo::<<'a> ||>();
687
- /// impl Foo<<'a> ||>() { ... }
688
- fn eat_lt ( & mut self , force : bool ) -> bool {
672
+ /// starting token.
673
+ fn eat_lt ( & mut self ) -> bool {
689
674
match self . token {
690
675
token:: Lt => { self . bump ( ) ; true }
691
676
token:: BinOp ( token:: Shl ) => {
692
- let next_lifetime = self . look_ahead ( 1 , |t| match * t {
693
- token:: Lifetime ( ..) => true ,
694
- _ => false ,
695
- } ) ;
696
- if force || next_lifetime {
697
- let span = self . span ;
698
- let lo = span. lo + BytePos ( 1 ) ;
699
- self . replace_token ( token:: Lt , lo, span. hi ) ;
700
- true
701
- } else {
702
- false
703
- }
677
+ let span = self . span ;
678
+ let lo = span. lo + BytePos ( 1 ) ;
679
+ self . replace_token ( token:: Lt , lo, span. hi ) ;
680
+ true
704
681
}
705
682
_ => false ,
706
683
}
707
684
}
708
685
709
686
fn expect_lt ( & mut self ) {
710
- if !self . eat_lt ( true ) {
687
+ if !self . eat_lt ( ) {
711
688
let found_token = self . this_token_to_string ( ) ;
712
689
let token_str = Parser :: token_to_string ( & token:: Lt ) ;
713
690
self . fatal ( format ! ( "expected `{}`, found `{}`" ,
@@ -1582,9 +1559,8 @@ impl<'a> Parser<'a> {
1582
1559
TyTypeof ( e)
1583
1560
} else if self . eat_keyword ( keywords:: Proc ) {
1584
1561
self . parse_proc_type ( Vec :: new ( ) )
1585
- } else if self . check ( & token :: Lt ) {
1562
+ } else if self . eat_lt ( ) {
1586
1563
// QUALIFIED PATH `<TYPE as TRAIT_REF>::item`
1587
- self . bump ( ) ;
1588
1564
let self_type = self . parse_ty_sum ( ) ;
1589
1565
self . expect_keyword ( keywords:: As ) ;
1590
1566
let trait_ref = self . parse_trait_ref ( ) ;
@@ -1870,7 +1846,7 @@ impl<'a> Parser<'a> {
1870
1846
let identifier = self . parse_ident ( ) ;
1871
1847
1872
1848
// Parse types, optionally.
1873
- let parameters = if self . eat_lt ( false ) {
1849
+ let parameters = if self . eat_lt ( ) {
1874
1850
let ( lifetimes, types, bindings) = self . parse_generic_values_after_lt ( ) ;
1875
1851
1876
1852
ast:: AngleBracketedParameters ( ast:: AngleBracketedParameterData {
@@ -1931,7 +1907,7 @@ impl<'a> Parser<'a> {
1931
1907
}
1932
1908
1933
1909
// Check for a type segment.
1934
- if self . eat_lt ( false ) {
1910
+ if self . eat_lt ( ) {
1935
1911
// Consumed `a::b::<`, go look for types
1936
1912
let ( lifetimes, types, bindings) = self . parse_generic_values_after_lt ( ) ;
1937
1913
segments. push ( ast:: PathSegment {
0 commit comments