99// except according to those terms.
1010
1111use abi:: { self , Abi } ;
12- use ast:: { AttrStyle , BareFnTy } ;
12+ use ast:: { AngleBracketedParameterData , AttrStyle , BareFnTy } ;
1313use ast:: { RegionTyParamBound , TraitTyParamBound , TraitBoundModifier } ;
1414use ast:: Unsafety ;
1515use ast:: { Mod , Arg , Arm , Attribute , BindingMode , TraitItemKind } ;
@@ -1831,11 +1831,7 @@ impl<'a> Parser<'a> {
18311831 let parameters = if parse_generics && self . eat_lt ( ) {
18321832 let ( lifetimes, types, bindings) = self . parse_generic_args ( ) ?;
18331833 self . expect_gt ( ) ?;
1834- ast:: AngleBracketedParameterData {
1835- lifetimes : lifetimes,
1836- types : types,
1837- bindings : bindings,
1838- } . into ( )
1834+ AngleBracketedParameterData { lifetimes, types, bindings } . into ( )
18391835 } else if self . eat ( & token:: OpenDelim ( token:: Paren ) ) {
18401836 let lo = self . prev_span ;
18411837
@@ -1898,11 +1894,7 @@ impl<'a> Parser<'a> {
18981894 segments. push ( PathSegment {
18991895 identifier : identifier,
19001896 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 ( ) ,
19061898 } ) ;
19071899
19081900 // Consumed `a::b::<T,U>`, check for `::` before proceeding
@@ -2023,14 +2015,6 @@ impl<'a> Parser<'a> {
20232015 ExprKind :: Call ( f, args)
20242016 }
20252017
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-
20342018 pub fn mk_index ( & mut self , expr : P < Expr > , idx : P < Expr > ) -> ast:: ExprKind {
20352019 ExprKind :: Index ( expr, idx)
20362020 }
@@ -2460,7 +2444,7 @@ impl<'a> Parser<'a> {
24602444 // parsing into an expression.
24612445 fn parse_dot_suffix ( & mut self , ident : Ident , ident_span : Span , self_value : P < Expr > , lo : Span )
24622446 -> PResult < ' a , P < Expr > > {
2463- let ( _ , tys , bindings) = if self . eat ( & token:: ModSep ) {
2447+ let ( lifetimes , types , bindings) = if self . eat ( & token:: ModSep ) {
24642448 self . expect_lt ( ) ?;
24652449 let args = self . parse_generic_args ( ) ?;
24662450 self . expect_gt ( ) ?;
@@ -2469,11 +2453,6 @@ impl<'a> Parser<'a> {
24692453 ( Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) )
24702454 } ;
24712455
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-
24772456 Ok ( match self . token {
24782457 // expr.f() method call.
24792458 token:: OpenDelim ( token:: Paren ) => {
@@ -2486,17 +2465,20 @@ impl<'a> Parser<'a> {
24862465 let hi = self . prev_span ;
24872466
24882467 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 ( ) )
24922474 }
24932475 // Field access.
24942476 _ => {
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 ") ;
25002482 }
25012483
25022484 let id = respan ( ident_span. to ( ident_span) , ident) ;
0 commit comments