From 244231720d29db856c5a28c0dda6c2efd7c9219a Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 7 Nov 2014 06:53:45 -0500 Subject: Update parser with `for` syntax --- src/libsyntax/ext/build.rs | 15 +++++++++++---- src/libsyntax/ext/deriving/generic/ty.rs | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/libsyntax/ext') diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 5921d630b89..862cbf3d7ca 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -68,10 +68,11 @@ pub trait AstBuilder { span: Span, id: ast::Ident, bounds: OwnedSlice, - unbound: Option, + unbound: Option, default: Option>) -> ast::TyParam; fn trait_ref(&self, path: ast::Path) -> ast::TraitRef; + fn poly_trait_ref(&self, path: ast::Path) -> ast::PolyTraitRef; fn typarambound(&self, path: ast::Path) -> ast::TyParamBound; fn lifetime(&self, span: Span, ident: ast::Name) -> ast::Lifetime; fn lifetime_def(&self, @@ -417,7 +418,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { span: Span, id: ast::Ident, bounds: OwnedSlice, - unbound: Option, + unbound: Option, default: Option>) -> ast::TyParam { ast::TyParam { ident: id, @@ -445,12 +446,18 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ast::TraitRef { path: path, ref_id: ast::DUMMY_NODE_ID, - lifetimes: Vec::new(), + } + } + + fn poly_trait_ref(&self, path: ast::Path) -> ast::PolyTraitRef { + ast::PolyTraitRef { + bound_lifetimes: Vec::new(), + trait_ref: self.trait_ref(path) } } fn typarambound(&self, path: ast::Path) -> ast::TyParamBound { - ast::TraitTyParamBound(self.trait_ref(path)) + ast::TraitTyParamBound(self.poly_trait_ref(path)) } fn lifetime(&self, span: Span, name: ast::Name) -> ast::Lifetime { diff --git a/src/libsyntax/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs index a90618a30b6..1ec1e3b1224 100644 --- a/src/libsyntax/ext/deriving/generic/ty.rs +++ b/src/libsyntax/ext/deriving/generic/ty.rs @@ -194,7 +194,7 @@ impl<'a> Ty<'a> { fn mk_ty_param(cx: &ExtCtxt, span: Span, name: &str, - bounds: &[Path], unbound: Option, + bounds: &[Path], unbound: Option, self_ident: Ident, self_generics: &Generics) -> ast::TyParam { let bounds = bounds.iter().map(|b| { @@ -220,7 +220,7 @@ fn mk_generics(lifetimes: Vec, ty_params: Vec) #[deriving(Clone)] pub struct LifetimeBounds<'a> { pub lifetimes: Vec<(&'a str, Vec<&'a str>)>, - pub bounds: Vec<(&'a str, Option, Vec>)>, + pub bounds: Vec<(&'a str, Option, Vec>)>, } impl<'a> LifetimeBounds<'a> { -- cgit 1.4.1-3-g733a5