From 035c01af93fd23f10e233a8a9b651af20744e1d1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 10 May 2013 15:57:27 -0400 Subject: Add BuiltinBounds to closure type: parse and handle subtyping, but do not integrate with kindck etc (requires a snapshot first) --- src/libsyntax/parse/parser.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/libsyntax/parse/parser.rs') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ce9bbe7e17a..25b45a5f3b5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -395,12 +395,13 @@ pub impl Parser { -> ty_ { /* - (&|~|@) ['r] [pure|unsafe] [once] fn <'lt> (S) -> T - ^~~~~~^ ^~~^ ^~~~~~~~~~~~^ ^~~~~^ ^~~~^ ^~^ ^ - | | | | | | | - | | | | | | Return type - | | | | | Argument types - | | | | Lifetimes + (&|~|@) ['r] [pure|unsafe] [once] fn [:Bounds] <'lt> (S) -> T + ^~~~~~^ ^~~^ ^~~~~~~~~~~~^ ^~~~~^ ^~~~~~~~^ ^~~~^ ^~^ ^ + | | | | | | | | + | | | | | | | Return type + | | | | | | Argument types + | | | | | Lifetimes + | | | | Closure bounds | | | Once-ness (a.k.a., affine) | | Purity | Lifetime bound @@ -414,6 +415,7 @@ pub impl Parser { let purity = self.parse_unsafety(); let onceness = parse_onceness(self); self.expect_keyword("fn"); + let bounds = self.parse_optional_ty_param_bounds(); if self.parse_fn_ty_sigil().is_some() { self.obsolete(*self.span, ObsoletePostFnTySigil); @@ -426,6 +428,7 @@ pub impl Parser { region: region, purity: purity, onceness: onceness, + bounds: bounds, decl: decl, lifetimes: lifetimes, }); @@ -2851,9 +2854,9 @@ pub impl Parser { // matches optbounds = ( ( : ( boundseq )? )? ) // where boundseq = ( bound + boundseq ) | bound // and bound = 'static | ty - fn parse_optional_ty_param_bounds(&self) -> @OptVec { + fn parse_optional_ty_param_bounds(&self) -> OptVec { if !self.eat(&token::COLON) { - return @opt_vec::Empty; + return opt_vec::Empty; } let mut result = opt_vec::Empty; @@ -2907,13 +2910,13 @@ pub impl Parser { } } - return @result; + return result; } // matches typaram = IDENT optbounds fn parse_ty_param(&self) -> TyParam { let ident = self.parse_ident(); - let bounds = self.parse_optional_ty_param_bounds(); + let bounds = @self.parse_optional_ty_param_bounds(); ast::TyParam { ident: ident, id: self.get_id(), bounds: bounds } } -- cgit 1.4.1-3-g733a5