9
9
// except according to those terms.
10
10
11
11
use abi:: { self , Abi } ;
12
- use ast:: { AttrStyle , BareFnTy } ;
12
+ use ast:: { AngleBracketedParameterData , AttrStyle , BareFnTy } ;
13
13
use ast:: { RegionTyParamBound , TraitTyParamBound , TraitBoundModifier } ;
14
14
use ast:: Unsafety ;
15
15
use ast:: { Mod , Arg , Arm , Attribute , BindingMode , TraitItemKind } ;
@@ -1831,11 +1831,7 @@ impl<'a> Parser<'a> {
1831
1831
let parameters = if parse_generics && self . eat_lt ( ) {
1832
1832
let ( lifetimes, types, bindings) = self . parse_generic_args ( ) ?;
1833
1833
self . expect_gt ( ) ?;
1834
- ast:: AngleBracketedParameterData {
1835
- lifetimes : lifetimes,
1836
- types : types,
1837
- bindings : bindings,
1838
- } . into ( )
1834
+ AngleBracketedParameterData { lifetimes, types, bindings } . into ( )
1839
1835
} else if self . eat ( & token:: OpenDelim ( token:: Paren ) ) {
1840
1836
let lo = self . prev_span ;
1841
1837
@@ -1898,11 +1894,7 @@ impl<'a> Parser<'a> {
1898
1894
segments. push ( PathSegment {
1899
1895
identifier : identifier,
1900
1896
span : ident_span,
1901
- parameters : ast:: AngleBracketedParameterData {
1902
- lifetimes : lifetimes,
1903
- types : types,
1904
- bindings : bindings,
1905
- } . into ( ) ,
1897
+ parameters : AngleBracketedParameterData { lifetimes, types, bindings } . into ( ) ,
1906
1898
} ) ;
1907
1899
1908
1900
// Consumed `a::b::<T,U>`, check for `::` before proceeding
@@ -2023,14 +2015,6 @@ impl<'a> Parser<'a> {
2023
2015
ExprKind :: Call ( f, args)
2024
2016
}
2025
2017
2026
- fn mk_method_call ( & mut self ,
2027
- ident : ast:: SpannedIdent ,
2028
- tps : Vec < P < Ty > > ,
2029
- args : Vec < P < Expr > > )
2030
- -> ast:: ExprKind {
2031
- ExprKind :: MethodCall ( ident, tps, args)
2032
- }
2033
-
2034
2018
pub fn mk_index ( & mut self , expr : P < Expr > , idx : P < Expr > ) -> ast:: ExprKind {
2035
2019
ExprKind :: Index ( expr, idx)
2036
2020
}
@@ -2460,7 +2444,7 @@ impl<'a> Parser<'a> {
2460
2444
// parsing into an expression.
2461
2445
fn parse_dot_suffix ( & mut self , ident : Ident , ident_span : Span , self_value : P < Expr > , lo : Span )
2462
2446
-> PResult < ' a , P < Expr > > {
2463
- let ( _ , tys , bindings) = if self . eat ( & token:: ModSep ) {
2447
+ let ( lifetimes , types , bindings) = if self . eat ( & token:: ModSep ) {
2464
2448
self . expect_lt ( ) ?;
2465
2449
let args = self . parse_generic_args ( ) ?;
2466
2450
self . expect_gt ( ) ?;
@@ -2469,11 +2453,6 @@ impl<'a> Parser<'a> {
2469
2453
( Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) )
2470
2454
} ;
2471
2455
2472
- if !bindings. is_empty ( ) {
2473
- let prev_span = self . prev_span ;
2474
- self . span_err ( prev_span, "type bindings are only permitted on trait paths" ) ;
2475
- }
2476
-
2477
2456
Ok ( match self . token {
2478
2457
// expr.f() method call.
2479
2458
token:: OpenDelim ( token:: Paren ) => {
@@ -2486,17 +2465,20 @@ impl<'a> Parser<'a> {
2486
2465
let hi = self . prev_span ;
2487
2466
2488
2467
es. insert ( 0 , self_value) ;
2489
- let id = respan ( ident_span. to ( ident_span) , ident) ;
2490
- let nd = self . mk_method_call ( id, tys, es) ;
2491
- self . mk_expr ( lo. to ( hi) , nd, ThinVec :: new ( ) )
2468
+ let seg = PathSegment {
2469
+ identifier : ident,
2470
+ span : ident_span. to ( ident_span) ,
2471
+ parameters : AngleBracketedParameterData { lifetimes, types, bindings } . into ( ) ,
2472
+ } ;
2473
+ self . mk_expr ( lo. to ( hi) , ExprKind :: MethodCall ( seg, es) , ThinVec :: new ( ) )
2492
2474
}
2493
2475
// Field access.
2494
2476
_ => {
2495
- if !tys . is_empty ( ) {
2496
- let prev_span = self . prev_span ;
2497
- self . span_err ( prev_span ,
2498
- "field expressions may not \
2499
- have type parameters ") ;
2477
+ if let Some ( generic_arg_span ) = lifetimes . get ( 0 ) . map ( |x| x . span ) . or_else ( ||
2478
+ types . get ( 0 ) . map ( |x| x . span ) ) . or_else ( ||
2479
+ bindings . get ( 0 ) . map ( |x| x . span ) ) {
2480
+ self . span_err ( generic_arg_span ,
2481
+ "field expressions may not have generic arguments ") ;
2500
2482
}
2501
2483
2502
2484
let id = respan ( ident_span. to ( ident_span) , ident) ;
0 commit comments