diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-03-20 01:52:37 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-03-22 09:54:18 +1100 |
| commit | e33676b7936b12bb68f47857ab3f8ea9b757d0d5 (patch) | |
| tree | 64e49bfdfb621bca44056fb4810c4f487f74940b /src/libsyntax/ext | |
| parent | 0384952a657e49d1f1cbab7c21dee91cd2c4f585 (diff) | |
| download | rust-e33676b7936b12bb68f47857ab3f8ea9b757d0d5.tar.gz rust-e33676b7936b12bb68f47857ab3f8ea9b757d0d5.zip | |
Migrate all users of opt_vec to owned_slice, delete opt_vec.
syntax::opt_vec is now entirely unused, and so can go.
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 33 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat_idents.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/ty.rs | 19 |
4 files changed, 31 insertions, 35 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index e860866ebf9..1106dc61db7 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -16,8 +16,7 @@ use codemap::{Span, respan, DUMMY_SP}; use ext::base::ExtCtxt; use ext::quote::rt::*; use fold::Folder; -use opt_vec; -use opt_vec::OptVec; +use owned_slice::OwnedSlice; use parse::token::special_idents; use parse::token; @@ -48,7 +47,7 @@ pub trait AstBuilder { fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy; fn ty(&self, span: Span, ty: ast::Ty_) -> P<ast::Ty>; - fn ty_path(&self, ast::Path, Option<OptVec<ast::TyParamBound>>) -> P<ast::Ty>; + fn ty_path(&self, ast::Path, Option<OwnedSlice<ast::TyParamBound>>) -> P<ast::Ty>; fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>; fn ty_rptr(&self, span: Span, @@ -61,14 +60,14 @@ pub trait AstBuilder { fn ty_infer(&self, sp: Span) -> P<ast::Ty>; fn ty_nil(&self) -> P<ast::Ty>; - fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> Vec<P<ast::Ty>> ; - fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> Vec<P<ast::Ty>> ; + fn ty_vars(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> ; + fn ty_vars_global(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> ; fn ty_field_imm(&self, span: Span, name: Ident, ty: P<ast::Ty>) -> ast::TypeField; fn strip_bounds(&self, bounds: &Generics) -> Generics; fn typaram(&self, id: ast::Ident, - bounds: OptVec<ast::TyParamBound>, + bounds: OwnedSlice<ast::TyParamBound>, default: Option<P<ast::Ty>>) -> ast::TyParam; fn trait_ref(&self, path: ast::Path) -> ast::TraitRef; @@ -274,13 +273,13 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ast::PathSegment { identifier: ident, lifetimes: Vec::new(), - types: opt_vec::Empty, + types: OwnedSlice::empty(), } }).collect(); segments.push(ast::PathSegment { identifier: last_identifier, lifetimes: lifetimes, - types: opt_vec::from(types), + types: OwnedSlice::from_vec(types), }); ast::Path { span: sp, @@ -304,7 +303,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { }) } - fn ty_path(&self, path: ast::Path, bounds: Option<OptVec<ast::TyParamBound>>) + fn ty_path(&self, path: ast::Path, bounds: Option<OwnedSlice<ast::TyParamBound>>) -> P<ast::Ty> { self.ty(path.span, ast::TyPath(path, bounds, ast::DUMMY_NODE_ID)) @@ -366,7 +365,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn typaram(&self, id: ast::Ident, - bounds: OptVec<ast::TyParamBound>, + bounds: OwnedSlice<ast::TyParamBound>, default: Option<P<ast::Ty>>) -> ast::TyParam { ast::TyParam { ident: id, @@ -379,20 +378,18 @@ impl<'a> AstBuilder for ExtCtxt<'a> { // these are strange, and probably shouldn't be used outside of // pipes. Specifically, the global version possible generates // incorrect code. - fn ty_vars(&self, ty_params: &OptVec<ast::TyParam>) -> Vec<P<ast::Ty>> { - opt_vec::take_vec( - ty_params.map(|p| self.ty_ident(DUMMY_SP, p.ident))) + fn ty_vars(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> { + ty_params.iter().map(|p| self.ty_ident(DUMMY_SP, p.ident)).collect() } - fn ty_vars_global(&self, ty_params: &OptVec<ast::TyParam>) -> Vec<P<ast::Ty>> { - opt_vec::take_vec( - ty_params.map(|p| self.ty_path( - self.path_global(DUMMY_SP, vec!(p.ident)), None))) + fn ty_vars_global(&self, ty_params: &OwnedSlice<ast::TyParam>) -> Vec<P<ast::Ty>> { + ty_params.iter().map(|p| self.ty_path( + self.path_global(DUMMY_SP, vec!(p.ident)), None)).collect() } fn strip_bounds(&self, generics: &Generics) -> Generics { let new_params = generics.ty_params.map(|ty_param| { - ast::TyParam { bounds: opt_vec::Empty, ..*ty_param } + ast::TyParam { bounds: OwnedSlice::empty(), ..*ty_param } }); Generics { ty_params: new_params, diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index 45a20afab7d..8441fa719ea 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -12,7 +12,7 @@ use ast; use codemap::Span; use ext::base::*; use ext::base; -use opt_vec; +use owned_slice::OwnedSlice; use parse::token; use parse::token::{str_to_ident}; @@ -52,7 +52,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) ast::PathSegment { identifier: res, lifetimes: Vec::new(), - types: opt_vec::Empty, + types: OwnedSlice::empty(), } ) } diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 7aa98a60781..89a8b2cd336 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -184,7 +184,7 @@ use ext::base::ExtCtxt; use ext::build::AstBuilder; use codemap; use codemap::Span; -use opt_vec; +use owned_slice::OwnedSlice; use parse::token::InternedString; use std::vec; @@ -362,7 +362,7 @@ impl<'a> TraitDef<'a> { let Generics { mut lifetimes, ty_params } = self.generics.to_generics(cx, self.span, type_ident, generics); - let mut ty_params = opt_vec::take_vec(ty_params); + let mut ty_params = ty_params.into_vec(); // Copy the lifetimes lifetimes.extend(&mut generics.lifetimes.iter().map(|l| *l)); @@ -380,11 +380,11 @@ impl<'a> TraitDef<'a> { // require the current trait bounds.push(cx.typarambound(trait_path.clone())); - cx.typaram(ty_param.ident, opt_vec::from(bounds), None) + cx.typaram(ty_param.ident, OwnedSlice::from_vec(bounds), None) })); let trait_generics = Generics { lifetimes: lifetimes, - ty_params: opt_vec::from(ty_params) + ty_params: OwnedSlice::from_vec(ty_params) }; // Create the reference to the trait. @@ -400,7 +400,7 @@ impl<'a> TraitDef<'a> { // Create the type of `self`. let self_type = cx.ty_path( cx.path_all(self.span, false, vec!( type_ident ), self_lifetimes, - opt_vec::take_vec(self_ty_params)), None); + self_ty_params.into_vec()), None); let attr = cx.attribute( self.span, diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index 5b29af185a4..bfdfba7ba78 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -18,7 +18,7 @@ use ast::{P,Expr,Generics,Ident}; use ext::base::ExtCtxt; use ext::build::AstBuilder; use codemap::{Span,respan}; -use opt_vec; +use owned_slice::OwnedSlice; /// The types of pointers pub enum PtrTy<'a> { @@ -116,11 +116,10 @@ fn mk_lifetime(cx: &ExtCtxt, span: Span, lt: &Option<&str>) -> Option<ast::Lifet } fn mk_lifetimes(cx: &ExtCtxt, span: Span, lt: &Option<&str>) -> Vec<ast::Lifetime> { - let lifetimes = match *lt { - Some(ref s) => opt_vec::with(cx.lifetime(span, cx.ident_of(*s).name)), - None => opt_vec::Empty - }; - opt_vec::take_vec(lifetimes) + match *lt { + Some(ref s) => vec!(cx.lifetime(span, cx.ident_of(*s).name)), + None => vec!() + } } impl<'a> Ty<'a> { @@ -173,7 +172,7 @@ impl<'a> Ty<'a> { let lifetimes = self_generics.lifetimes.clone(); cx.path_all(span, false, vec!(self_ty), lifetimes, - opt_vec::take_vec(self_params)) + self_params.into_vec()) } Literal(ref p) => { p.to_path(cx, span, self_ty, self_generics) @@ -187,18 +186,18 @@ impl<'a> Ty<'a> { fn mk_ty_param(cx: &ExtCtxt, span: Span, name: &str, bounds: &[Path], self_ident: Ident, self_generics: &Generics) -> ast::TyParam { - let bounds = opt_vec::from( + let bounds = bounds.iter().map(|b| { let path = b.to_path(cx, span, self_ident, self_generics); cx.typarambound(path) - }).collect()); + }).collect(); cx.typaram(cx.ident_of(name), bounds, None) } fn mk_generics(lifetimes: Vec<ast::Lifetime> , ty_params: Vec<ast::TyParam> ) -> Generics { Generics { lifetimes: lifetimes, - ty_params: opt_vec::from(ty_params) + ty_params: OwnedSlice::from_vec(ty_params) } } |
