diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 6420fcd9e50b4..0da1ff3e6f436 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -90,7 +90,6 @@ use std::cell::{Cell, RefCell}; use std::char::from_u32; use std::fmt; use syntax::ast; -use syntax::owned_slice::OwnedSlice; use syntax::codemap::{self, Pos, Span}; use syntax::parse::token; use syntax::ptr::P; @@ -1151,10 +1150,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { } fn rebuild_ty_params(&self, - ty_params: OwnedSlice, + ty_params: P<[hir::TyParam]>, lifetime: hir::Lifetime, region_names: &HashSet) - -> OwnedSlice { + -> P<[hir::TyParam]> { ty_params.map(|ty_param| { let bounds = self.rebuild_ty_param_bounds(ty_param.bounds.clone(), lifetime, @@ -1170,10 +1169,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { } fn rebuild_ty_param_bounds(&self, - ty_param_bounds: OwnedSlice, + ty_param_bounds: hir::TyParamBounds, lifetime: hir::Lifetime, region_names: &HashSet) - -> OwnedSlice { + -> hir::TyParamBounds { ty_param_bounds.map(|tpb| { match tpb { &hir::RegionTyParamBound(lt) => { @@ -1246,7 +1245,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { add: &Vec, keep: &HashSet, remove: &HashSet, - ty_params: OwnedSlice, + ty_params: P<[hir::TyParam]>, where_clause: hir::WhereClause) -> hir::Generics { let mut lifetimes = Vec::new(); diff --git a/src/librustc/middle/ty/structural_impls.rs b/src/librustc/middle/ty/structural_impls.rs index 41303b46dfd09..0928097db49c2 100644 --- a/src/librustc/middle/ty/structural_impls.rs +++ b/src/librustc/middle/ty/structural_impls.rs @@ -16,7 +16,7 @@ use middle::ty::fold::{TypeFoldable, TypeFolder}; use std::rc::Rc; use syntax::abi; -use syntax::owned_slice::OwnedSlice; +use syntax::ptr::P; use rustc_front::hir; @@ -555,8 +555,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder { } } -impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for OwnedSlice { - fn fold_with>(&self, folder: &mut F) -> OwnedSlice { +impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for P<[T]> { + fn fold_with>(&self, folder: &mut F) -> P<[T]> { self.iter().map(|t| t.fold_with(folder)).collect() } } diff --git a/src/librustc_front/fold.rs b/src/librustc_front/fold.rs index 88a34b27c3189..0978c3f78e82f 100644 --- a/src/librustc_front/fold.rs +++ b/src/librustc_front/fold.rs @@ -17,7 +17,6 @@ use syntax::ast::{MetaWord, MetaList, MetaNameValue}; use syntax::attr::ThinAttributesExt; use hir; use syntax::codemap::{respan, Span, Spanned}; -use syntax::owned_slice::OwnedSlice; use syntax::ptr::P; use syntax::parse::token; use syntax::util::move_map::MoveMap; @@ -211,7 +210,7 @@ pub trait Folder : Sized { noop_fold_ty_param(tp, self) } - fn fold_ty_params(&mut self, tps: OwnedSlice) -> OwnedSlice { + fn fold_ty_params(&mut self, tps: P<[TyParam]>) -> P<[TyParam]> { noop_fold_ty_params(tps, self) } @@ -220,12 +219,12 @@ pub trait Folder : Sized { } fn fold_opt_bounds(&mut self, - b: Option>) - -> Option> { + b: Option) + -> Option { noop_fold_opt_bounds(b, self) } - fn fold_bounds(&mut self, b: OwnedSlice) -> OwnedSlice { + fn fold_bounds(&mut self, b: TyParamBounds) -> TyParamBounds { noop_fold_bounds(b, self) } @@ -576,9 +575,9 @@ pub fn noop_fold_ty_param(tp: TyParam, fld: &mut T) -> TyParam { } } -pub fn noop_fold_ty_params(tps: OwnedSlice, +pub fn noop_fold_ty_params(tps: P<[TyParam]>, fld: &mut T) - -> OwnedSlice { + -> P<[TyParam]> { tps.move_map(|tp| fld.fold_ty_param(tp)) } @@ -726,9 +725,9 @@ pub fn noop_fold_mt(MutTy { ty, mutbl }: MutTy, folder: &mut T) -> Mu } } -pub fn noop_fold_opt_bounds(b: Option>, +pub fn noop_fold_opt_bounds(b: Option, folder: &mut T) - -> Option> { + -> Option { b.map(|bounds| folder.fold_bounds(bounds)) } diff --git a/src/librustc_front/hir.rs b/src/librustc_front/hir.rs index d1cb82dbeccbc..1491ecc89af1f 100644 --- a/src/librustc_front/hir.rs +++ b/src/librustc_front/hir.rs @@ -42,7 +42,6 @@ use syntax::abi::Abi; use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect}; use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, CrateConfig}; use syntax::attr::ThinAttributes; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token::InternedString; use syntax::ptr::P; @@ -193,8 +192,8 @@ impl PathParameters { pub fn none() -> PathParameters { AngleBracketedParameters(AngleBracketedParameterData { lifetimes: Vec::new(), - types: OwnedSlice::empty(), - bindings: OwnedSlice::empty(), + types: P::empty(), + bindings: P::empty(), }) } @@ -267,10 +266,10 @@ pub struct AngleBracketedParameterData { /// The lifetime parameters for this path segment. pub lifetimes: Vec, /// The type parameters for this path segment, if present. - pub types: OwnedSlice>, + pub types: P<[P]>, /// Bindings (equality constraints) on associated types, if present. /// E.g., `Foo`. - pub bindings: OwnedSlice, + pub bindings: P<[TypeBinding]>, } impl AngleBracketedParameterData { @@ -310,7 +309,7 @@ pub enum TraitBoundModifier { Maybe, } -pub type TyParamBounds = OwnedSlice; +pub type TyParamBounds = P<[TyParamBound]>; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct TyParam { @@ -326,7 +325,7 @@ pub struct TyParam { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Generics { pub lifetimes: Vec, - pub ty_params: OwnedSlice, + pub ty_params: P<[TyParam]>, pub where_clause: WhereClause, } @@ -369,7 +368,7 @@ pub struct WhereBoundPredicate { /// The type being bounded pub bounded_ty: P, /// Trait and lifetime bounds (`Clone+Send+'static`) - pub bounds: OwnedSlice, + pub bounds: TyParamBounds, } /// A lifetime predicate, e.g. `'a: 'b+'c` diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index c0b10fb89124a..614f6f0bd36dd 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -70,7 +70,6 @@ use syntax::attr::{ThinAttributes, ThinAttributesExt}; use syntax::ext::mtwt; use syntax::ptr::P; use syntax::codemap::{respan, Spanned, Span}; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token; use syntax::std_inject; use syntax::visit::{self, Visitor}; @@ -430,8 +429,8 @@ pub fn lower_ty_param(lctx: &LoweringContext, tp: &TyParam) -> hir::TyParam { } pub fn lower_ty_params(lctx: &LoweringContext, - tps: &OwnedSlice) - -> OwnedSlice { + tps: &P<[TyParam]>) + -> P<[hir::TyParam]> { tps.iter().map(|tp| lower_ty_param(lctx, tp)).collect() } @@ -583,8 +582,8 @@ pub fn lower_mt(lctx: &LoweringContext, mt: &MutTy) -> hir::MutTy { } pub fn lower_opt_bounds(lctx: &LoweringContext, - b: &Option>) - -> Option> { + b: &Option) + -> Option { b.as_ref().map(|ref bounds| lower_bounds(lctx, bounds)) } @@ -1795,8 +1794,8 @@ fn path_all(sp: Span, identifier: last_identifier, parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }), }); hir::Path { diff --git a/src/librustc_front/print/pprust.rs b/src/librustc_front/print/pprust.rs index 81076b6e40276..a3bb005dfbdca 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -12,7 +12,6 @@ pub use self::AnnNode::*; use syntax::abi; use syntax::ast; -use syntax::owned_slice::OwnedSlice; use syntax::codemap::{self, CodeMap, BytePos, Spanned}; use syntax::diagnostic; use syntax::parse::token::{self, BinOpToken}; @@ -519,7 +518,7 @@ impl<'a> State<'a> { hir::TyBareFn(ref f) => { let generics = hir::Generics { lifetimes: f.lifetimes.clone(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: hir::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), @@ -2258,7 +2257,7 @@ impl<'a> State<'a> { } let generics = hir::Generics { lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: hir::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), diff --git a/src/librustc_front/util.rs b/src/librustc_front/util.rs index 4dc08f7a0485a..f85eb2bb4011e 100644 --- a/src/librustc_front/util.rs +++ b/src/librustc_front/util.rs @@ -15,7 +15,6 @@ use syntax::ast_util; use syntax::ast::{Name, NodeId, DUMMY_NODE_ID}; use syntax::codemap::Span; use syntax::ptr::P; -use syntax::owned_slice::OwnedSlice; pub fn walk_pat(pat: &Pat, mut it: F) -> bool where F: FnMut(&Pat) -> bool @@ -336,7 +335,7 @@ pub fn is_path(e: P) -> bool { pub fn empty_generics() -> Generics { Generics { lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: WhereClause { id: DUMMY_NODE_ID, predicates: Vec::new(), @@ -354,8 +353,8 @@ pub fn ident_to_path(s: Span, ident: Ident) -> Path { identifier: ident, parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData { lifetimes: Vec::new(), - types: OwnedSlice::empty(), - bindings: OwnedSlice::empty(), + types: P::empty(), + bindings: P::empty(), }), }), } diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index 2964d87ec1c09..414b8cd93ea17 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -42,7 +42,6 @@ use std::path::Path; use syntax::ast::{self, NodeId}; use syntax::codemap::*; use syntax::parse::token::{self, keywords}; -use syntax::owned_slice::OwnedSlice; use syntax::visit::{self, Visitor}; use syntax::print::pprust::{path_to_string, ty_to_string}; use syntax::ptr::P; @@ -573,7 +572,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { fn process_trait(&mut self, item: &ast::Item, generics: &ast::Generics, - trait_refs: &OwnedSlice, + trait_refs: &ast::TyParamBounds, methods: &[P]) { let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); let val = self.span.snippet(item.span); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index f348d5411c347..b8c0e88ad297d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -119,7 +119,6 @@ use syntax::ast; use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::codemap::{self, Span, Spanned}; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token::{self, InternedString}; use syntax::ptr::P; use syntax::util::lev_distance::lev_distance; @@ -4905,7 +4904,7 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &hir::Block) -> bool { } pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, - tps: &OwnedSlice, + tps: &P<[hir::TyParam]>, ty: Ty<'tcx>) { debug!("check_bounds_are_used(n_tps={}, ty={:?})", tps.len(), ty); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 52eeb781b31cc..e217e7afad737 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -112,7 +112,7 @@ impl Clean for ty::Binder where T: Clean { } } -impl, U> Clean> for syntax::owned_slice::OwnedSlice { +impl, U> Clean> for P<[T]> { fn clean(&self, cx: &DocContext) -> Vec { self.iter().map(|x| x.clean(cx)).collect() } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b56846327c3b0..41af509c53994 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -50,7 +50,6 @@ use codemap::{Span, Spanned, DUMMY_SP, ExpnId}; use abi::Abi; use ext::base; use ext::tt::macro_parser; -use owned_slice::OwnedSlice; use parse::token::{InternedString, str_to_ident}; use parse::token; use parse::lexer; @@ -261,8 +260,8 @@ impl PathParameters { pub fn none() -> PathParameters { AngleBracketedParameters(AngleBracketedParameterData { lifetimes: Vec::new(), - types: OwnedSlice::empty(), - bindings: OwnedSlice::empty(), + types: P::empty(), + bindings: P::empty(), }) } @@ -334,10 +333,10 @@ pub struct AngleBracketedParameterData { /// The lifetime parameters for this path segment. pub lifetimes: Vec, /// The type parameters for this path segment, if present. - pub types: OwnedSlice>, + pub types: P<[P]>, /// Bindings (equality constraints) on associated types, if present. /// E.g., `Foo`. - pub bindings: OwnedSlice>, + pub bindings: P<[P]>, } impl AngleBracketedParameterData { @@ -394,7 +393,7 @@ pub enum TraitBoundModifier { Maybe, } -pub type TyParamBounds = OwnedSlice; +pub type TyParamBounds = P<[TyParamBound]>; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct TyParam { @@ -410,7 +409,7 @@ pub struct TyParam { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Generics { pub lifetimes: Vec, - pub ty_params: OwnedSlice, + pub ty_params: P<[TyParam]>, pub where_clause: WhereClause, } @@ -430,7 +429,7 @@ impl Default for Generics { fn default() -> Generics { Generics { lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: WhereClause { id: DUMMY_NODE_ID, predicates: Vec::new(), @@ -466,7 +465,7 @@ pub struct WhereBoundPredicate { /// The type being bounded pub bounded_ty: P, /// Trait and lifetime bounds (`Clone+Send+'static`) - pub bounds: OwnedSlice, + pub bounds: TyParamBounds, } /// A lifetime predicate, e.g. `'a: 'b+'c` diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 3d3d53477494d..d38b771814c28 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -12,7 +12,6 @@ use ast::*; use ast; use codemap; use codemap::Span; -use owned_slice::OwnedSlice; use parse::token; use print::pprust; use ptr::P; @@ -43,8 +42,8 @@ pub fn ident_to_path(s: Span, identifier: Ident) -> Path { identifier: identifier, parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: Vec::new(), - types: OwnedSlice::empty(), - bindings: OwnedSlice::empty(), + types: P::empty(), + bindings: P::empty(), }) } ), diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index cdc9cb024530d..46a39b98058a2 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -14,7 +14,6 @@ use ast; use attr; use codemap::{Span, respan, Spanned, DUMMY_SP, Pos}; use ext::base::ExtCtxt; -use owned_slice::OwnedSlice; use parse::token::special_idents; use parse::token::InternedString; use parse::token; @@ -56,7 +55,7 @@ pub trait AstBuilder { fn ty(&self, span: Span, ty: ast::Ty_) -> P; fn ty_path(&self, ast::Path) -> P; - fn ty_sum(&self, ast::Path, OwnedSlice) -> P; + fn ty_sum(&self, ast::Path, ast::TyParamBounds) -> P; fn ty_ident(&self, span: Span, idents: ast::Ident) -> P; fn ty_rptr(&self, span: Span, @@ -70,13 +69,13 @@ pub trait AstBuilder { fn ty_option(&self, ty: P) -> P; fn ty_infer(&self, sp: Span) -> P; - fn ty_vars(&self, ty_params: &OwnedSlice) -> Vec> ; - fn ty_vars_global(&self, ty_params: &OwnedSlice) -> Vec> ; + fn ty_vars(&self, ty_params: &P<[ast::TyParam]>) -> Vec> ; + fn ty_vars_global(&self, ty_params: &P<[ast::TyParam]>) -> Vec> ; fn typaram(&self, span: Span, id: ast::Ident, - bounds: OwnedSlice, + bounds: ast::TyParamBounds, default: Option>) -> ast::TyParam; fn trait_ref(&self, path: ast::Path) -> ast::TraitRef; @@ -331,8 +330,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { identifier: last_identifier, parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }) }); ast::Path { @@ -369,8 +368,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { identifier: ident, parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }) }); @@ -399,7 +398,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.ty(path.span, ast::TyPath(None, path)) } - fn ty_sum(&self, path: ast::Path, bounds: OwnedSlice) -> P { + fn ty_sum(&self, path: ast::Path, bounds: ast::TyParamBounds) -> P { self.ty(path.span, ast::TyObjectSum(self.ty_path(path), bounds)) @@ -448,7 +447,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn typaram(&self, span: Span, id: ast::Ident, - bounds: OwnedSlice, + bounds: ast::TyParamBounds, default: Option>) -> ast::TyParam { ast::TyParam { ident: id, @@ -462,11 +461,11 @@ 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: &OwnedSlice) -> Vec> { + fn ty_vars(&self, ty_params: &P<[ast::TyParam]>) -> Vec> { ty_params.iter().map(|p| self.ty_ident(DUMMY_SP, p.ident)).collect() } - fn ty_vars_global(&self, ty_params: &OwnedSlice) -> Vec> { + fn ty_vars_global(&self, ty_params: &P<[ast::TyParam]>) -> Vec> { ty_params .iter() .map(|p| self.ty_path(self.path_global(DUMMY_SP, vec!(p.ident)))) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index c637813f07e5b..ccc37319c2a04 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -23,7 +23,6 @@ use ast; use attr::{ThinAttributes, ThinAttributesExt}; use ast_util; use codemap::{respan, Span, Spanned}; -use owned_slice::OwnedSlice; use parse::token; use ptr::P; use util::small_vector::SmallVector; @@ -233,7 +232,7 @@ pub trait Folder : Sized { noop_fold_ty_param(tp, self) } - fn fold_ty_params(&mut self, tps: OwnedSlice) -> OwnedSlice { + fn fold_ty_params(&mut self, tps: P<[TyParam]>) -> P<[TyParam]> { noop_fold_ty_params(tps, self) } @@ -257,13 +256,13 @@ pub trait Folder : Sized { noop_fold_opt_lifetime(o_lt, self) } - fn fold_opt_bounds(&mut self, b: Option>) - -> Option> { + fn fold_opt_bounds(&mut self, b: Option) + -> Option { noop_fold_opt_bounds(b, self) } - fn fold_bounds(&mut self, b: OwnedSlice) - -> OwnedSlice { + fn fold_bounds(&mut self, b: TyParamBounds) + -> TyParamBounds { noop_fold_bounds(b, self) } @@ -713,8 +712,8 @@ pub fn noop_fold_ty_param(tp: TyParam, fld: &mut T) -> TyParam { } } -pub fn noop_fold_ty_params(tps: OwnedSlice, fld: &mut T) - -> OwnedSlice { +pub fn noop_fold_ty_params(tps: P<[TyParam]>, fld: &mut T) + -> P<[TyParam]> { tps.move_map(|tp| fld.fold_ty_param(tp)) } @@ -870,8 +869,8 @@ pub fn noop_fold_mt(MutTy {ty, mutbl}: MutTy, folder: &mut T) -> MutT } } -pub fn noop_fold_opt_bounds(b: Option>, folder: &mut T) - -> Option> { +pub fn noop_fold_opt_bounds(b: Option, folder: &mut T) + -> Option { b.map(|bounds| folder.fold_bounds(bounds)) } diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index 820c7e7e4a663..33a3d5785981a 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -9,4 +9,6 @@ // except according to those terms. /// A non-growable owned slice. +#[unstable(feature = "rustc_private", issue = "0")] +#[rustc_deprecated(since = "1.7.0", reason = "use `ptr::P<[T]>` instead")] pub type OwnedSlice = ::ptr::P<[T]>; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index e9c8173a4d980..df2a9f30c7acf 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -668,7 +668,6 @@ mod tests { use super::*; use std::rc::Rc; use codemap::{Span, BytePos, Pos, Spanned, NO_EXPANSION}; - use owned_slice::OwnedSlice; use ast::{self, TokenTree}; use abi; use attr::{first_attr_value_str_by_name, AttrMetaMethods}; @@ -944,7 +943,7 @@ mod tests { abi::Rust, ast::Generics{ // no idea on either of these: lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9398f1a573335..3732875c5c73e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -50,7 +50,7 @@ use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef}; use ast::{Ty, Ty_, TypeBinding, TyMac}; use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer}; -use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr}; +use ast::{TyParam, TyParamBounds, TyParen, TyPath, TyPolyTraitRef, TyPtr}; use ast::{TyRptr, TyTup, TyU32, TyVec}; use ast::TypeTraitItem; use ast::{UnnamedField, UnsafeBlock}; @@ -73,7 +73,6 @@ use parse::{new_sub_parser_from_file, ParseSess}; use util::parser::{AssocOp, Fixity}; use print::pprust; use ptr::P; -use owned_slice::OwnedSlice; use parse::PResult; use diagnostic::FatalError; @@ -752,7 +751,7 @@ impl<'a> Parser<'a> { pub fn parse_seq_to_before_gt_or_return(&mut self, sep: Option, mut f: F) - -> PResult<(OwnedSlice, bool)> where + -> PResult<(P<[T]>, bool)> where F: FnMut(&mut Parser) -> PResult>, { let mut v = Vec::new(); @@ -773,7 +772,7 @@ impl<'a> Parser<'a> { if i % 2 == 0 { match try!(f(self)) { Some(result) => v.push(result), - None => return Ok((OwnedSlice::from_vec(v), true)) + None => return Ok((P::from_vec(v), true)) } } else { if let Some(t) = sep.as_ref() { @@ -782,7 +781,7 @@ impl<'a> Parser<'a> { } } - return Ok((OwnedSlice::from_vec(v), false)); + return Ok((P::from_vec(v), false)); } /// Parse a sequence bracketed by '<' and '>', stopping @@ -790,7 +789,7 @@ impl<'a> Parser<'a> { pub fn parse_seq_to_before_gt(&mut self, sep: Option, mut f: F) - -> PResult> where + -> PResult> where F: FnMut(&mut Parser) -> PResult, { let (result, returned) = try!(self.parse_seq_to_before_gt_or_return(sep, @@ -802,7 +801,7 @@ impl<'a> Parser<'a> { pub fn parse_seq_to_gt(&mut self, sep: Option, f: F) - -> PResult> where + -> PResult> where F: FnMut(&mut Parser) -> PResult, { let v = try!(self.parse_seq_to_before_gt(sep, f)); @@ -813,7 +812,7 @@ impl<'a> Parser<'a> { pub fn parse_seq_to_gt_or_return(&mut self, sep: Option, f: F) - -> PResult<(OwnedSlice, bool)> where + -> PResult<(P<[T]>, bool)> where F: FnMut(&mut Parser) -> PResult>, { let (v, returned) = try!(self.parse_seq_to_before_gt_or_return(sep, f)); @@ -1077,7 +1076,7 @@ impl<'a> Parser<'a> { let other_bounds = if try!(self.eat(&token::BinOp(token::Plus)) ){ try!(self.parse_ty_param_bounds(BoundParsingMode::Bare)) } else { - OwnedSlice::empty() + P::empty() }; let all_bounds = Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter() @@ -1710,8 +1709,8 @@ impl<'a> Parser<'a> { ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }) } else if try!(self.eat(&token::OpenDelim(token::Paren)) ){ let lo = self.last_span.lo; @@ -1774,8 +1773,8 @@ impl<'a> Parser<'a> { identifier: identifier, parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }), }); @@ -3883,10 +3882,10 @@ impl<'a> Parser<'a> { // otherwise returns empty list. fn parse_colon_then_ty_param_bounds(&mut self, mode: BoundParsingMode) - -> PResult> + -> PResult { if !try!(self.eat(&token::Colon) ){ - Ok(OwnedSlice::empty()) + Ok(P::empty()) } else { self.parse_ty_param_bounds(mode) } @@ -3898,7 +3897,7 @@ impl<'a> Parser<'a> { // and bound = 'region | trait_ref fn parse_ty_param_bounds(&mut self, mode: BoundParsingMode) - -> PResult> + -> PResult { let mut result = vec!(); loop { @@ -3940,7 +3939,7 @@ impl<'a> Parser<'a> { } } - return Ok(OwnedSlice::from_vec(result)); + return Ok(P::from_vec(result)); } /// Matches typaram = IDENT (`?` unbound)? optbounds ( EQ ty )? diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 0be62bc0a7f08..4ee51ee267232 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -17,7 +17,6 @@ use ast::Attribute; use attr::ThinAttributesExt; use util::parser::AssocOp; use attr; -use owned_slice::OwnedSlice; use attr::{AttrMetaMethods, AttributeMethods}; use codemap::{self, CodeMap, BytePos}; use diagnostic; @@ -1001,7 +1000,7 @@ impl<'a> State<'a> { ast::TyBareFn(ref f) => { let generics = ast::Generics { lifetimes: f.lifetimes.clone(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), @@ -3024,7 +3023,7 @@ impl<'a> State<'a> { } let generics = ast::Generics { lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 63fbe284a09fd..e9581b9e05c57 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -32,7 +32,6 @@ use ext::expand::ExpansionConfig; use fold::Folder; use util::move_map::MoveMap; use fold; -use owned_slice::OwnedSlice; use parse::token::{intern, InternedString}; use parse::{token, ParseSess}; use print::pprust; diff --git a/src/libsyntax/util/move_map.rs b/src/libsyntax/util/move_map.rs index 95c24c66630f0..e1078b719bf06 100644 --- a/src/libsyntax/util/move_map.rs +++ b/src/libsyntax/util/move_map.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use owned_slice::OwnedSlice; - use std::ptr; pub trait MoveMap: Sized { @@ -69,11 +67,11 @@ impl MoveMap for Vec { } } -impl MoveMap for OwnedSlice { +impl MoveMap for ::ptr::P<[T]> { fn move_flat_map(self, f: F) -> Self where F: FnMut(T) -> I, I: IntoIterator { - OwnedSlice::from_vec(self.into_vec().move_flat_map(f)) + ::ptr::P::from_vec(self.into_vec().move_flat_map(f)) } } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 5977144dae708..852458422685b 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -205,7 +205,6 @@ use syntax::codemap::{self, DUMMY_SP}; use syntax::codemap::Span; use syntax::diagnostic::SpanHandler; use syntax::util::move_map::MoveMap; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token::{intern, InternedString}; use syntax::parse::token::special_idents; use syntax::ptr::P; @@ -516,7 +515,7 @@ impl<'a> TraitDef<'a> { cx.typaram(self.span, ty_param.ident, - OwnedSlice::from_vec(bounds), + P::from_vec(bounds), None) })); @@ -528,7 +527,7 @@ impl<'a> TraitDef<'a> { span: self.span, bound_lifetimes: wb.bound_lifetimes.clone(), bounded_ty: wb.bounded_ty.clone(), - bounds: OwnedSlice::from_vec(wb.bounds.iter().cloned().collect()) + bounds: P::from_vec(wb.bounds.iter().cloned().collect()) }) } ast::WherePredicate::RegionPredicate(ref rb) => { @@ -579,7 +578,7 @@ impl<'a> TraitDef<'a> { span: self.span, bound_lifetimes: vec![], bounded_ty: ty, - bounds: OwnedSlice::from_vec(bounds), + bounds: P::from_vec(bounds), }; let predicate = ast::WherePredicate::BoundPredicate(predicate); @@ -590,7 +589,7 @@ impl<'a> TraitDef<'a> { let trait_generics = Generics { lifetimes: lifetimes, - ty_params: OwnedSlice::from_vec(ty_params), + ty_params: P::from_vec(ty_params), where_clause: where_clause }; diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 0c4a81361aef2..10564b5f6985b 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -19,7 +19,6 @@ use syntax::ast::{Expr,Generics,Ident}; use syntax::ext::base::ExtCtxt; use syntax::ext::build::AstBuilder; use syntax::codemap::{Span,respan}; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token::special_idents; use syntax::ptr::P; @@ -209,7 +208,7 @@ fn mk_generics(lifetimes: Vec, ty_params: Vec) -> Generics { Generics { lifetimes: lifetimes, - ty_params: OwnedSlice::from_vec(ty_params), + ty_params: P::from_vec(ty_params), where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(),