diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2013-05-10 15:57:27 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2013-05-16 14:21:02 -0400 |
| commit | 035c01af93fd23f10e233a8a9b651af20744e1d1 (patch) | |
| tree | 226edd1b4ba496dedd2c4aeb450b49384d0845d6 /src/libsyntax | |
| parent | 53196bb364426fb2b8db16f6748836779cd031c7 (diff) | |
| download | rust-035c01af93fd23f10e233a8a9b651af20744e1d1.tar.gz rust-035c01af93fd23f10e233a8a9b651af20744e1d1.zip | |
Add BuiltinBounds to closure type: parse and handle subtyping,
but do not integrate with kindck etc (requires a snapshot first)
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 23 |
3 files changed, 16 insertions, 11 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 4a3ae7d94ad..dcbbd7ab531 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -828,7 +828,8 @@ pub struct TyClosure { lifetimes: OptVec<Lifetime>, purity: purity, onceness: Onceness, - decl: fn_decl + decl: fn_decl, + bounds: OptVec<TyParamBound> } #[deriving(Eq, Encodable, Decodable)] diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index f6dbbbf420d..275a7b963a4 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -589,6 +589,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ { purity: f.purity, region: f.region, onceness: f.onceness, + bounds: f.bounds.map(|x| fold_ty_param_bound(x, fld)), decl: fold_fn_decl(&f.decl, fld), lifetimes: copy f.lifetimes, }) 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<TyParamBound> { + fn parse_optional_ty_param_bounds(&self) -> OptVec<TyParamBound> { 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 } } |
