Skip to content

Commit

Permalink
Deprecate name OwnedSlice and don't use it
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Dec 17, 2015
1 parent 09d4a43 commit 0d298f9
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 114 deletions.
11 changes: 5 additions & 6 deletions src/librustc/middle/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1154,10 +1153,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
}

fn rebuild_ty_params(&self,
ty_params: OwnedSlice<hir::TyParam>,
ty_params: P<[hir::TyParam]>,
lifetime: hir::Lifetime,
region_names: &HashSet<ast::Name>)
-> OwnedSlice<hir::TyParam> {
-> P<[hir::TyParam]> {
ty_params.map(|ty_param| {
let bounds = self.rebuild_ty_param_bounds(ty_param.bounds.clone(),
lifetime,
Expand All @@ -1173,10 +1172,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
}

fn rebuild_ty_param_bounds(&self,
ty_param_bounds: OwnedSlice<hir::TyParamBound>,
ty_param_bounds: hir::TyParamBounds,
lifetime: hir::Lifetime,
region_names: &HashSet<ast::Name>)
-> OwnedSlice<hir::TyParamBound> {
-> hir::TyParamBounds {
ty_param_bounds.map(|tpb| {
match tpb {
&hir::RegionTyParamBound(lt) => {
Expand Down Expand Up @@ -1249,7 +1248,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
add: &Vec<hir::Lifetime>,
keep: &HashSet<ast::Name>,
remove: &HashSet<ast::Name>,
ty_params: OwnedSlice<hir::TyParam>,
ty_params: P<[hir::TyParam]>,
where_clause: hir::WhereClause)
-> hir::Generics {
let mut lifetimes = Vec::new();
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -555,8 +555,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
}
}

impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for OwnedSlice<T> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> OwnedSlice<T> {
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for P<[T]> {
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> P<[T]> {
self.iter().map(|t| t.fold_with(folder)).collect()
}
}
Expand Down
17 changes: 8 additions & 9 deletions src/librustc_front/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -211,7 +210,7 @@ pub trait Folder : Sized {
noop_fold_ty_param(tp, self)
}

fn fold_ty_params(&mut self, tps: OwnedSlice<TyParam>) -> OwnedSlice<TyParam> {
fn fold_ty_params(&mut self, tps: P<[TyParam]>) -> P<[TyParam]> {
noop_fold_ty_params(tps, self)
}

Expand All @@ -220,12 +219,12 @@ pub trait Folder : Sized {
}

fn fold_opt_bounds(&mut self,
b: Option<OwnedSlice<TyParamBound>>)
-> Option<OwnedSlice<TyParamBound>> {
b: Option<TyParamBounds>)
-> Option<TyParamBounds> {
noop_fold_opt_bounds(b, self)
}

fn fold_bounds(&mut self, b: OwnedSlice<TyParamBound>) -> OwnedSlice<TyParamBound> {
fn fold_bounds(&mut self, b: TyParamBounds) -> TyParamBounds {
noop_fold_bounds(b, self)
}

Expand Down Expand Up @@ -576,9 +575,9 @@ pub fn noop_fold_ty_param<T: Folder>(tp: TyParam, fld: &mut T) -> TyParam {
}
}

pub fn noop_fold_ty_params<T: Folder>(tps: OwnedSlice<TyParam>,
pub fn noop_fold_ty_params<T: Folder>(tps: P<[TyParam]>,
fld: &mut T)
-> OwnedSlice<TyParam> {
-> P<[TyParam]> {
tps.move_map(|tp| fld.fold_ty_param(tp))
}

Expand Down Expand Up @@ -726,9 +725,9 @@ pub fn noop_fold_mt<T: Folder>(MutTy { ty, mutbl }: MutTy, folder: &mut T) -> Mu
}
}

pub fn noop_fold_opt_bounds<T: Folder>(b: Option<OwnedSlice<TyParamBound>>,
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<TyParamBounds>,
folder: &mut T)
-> Option<OwnedSlice<TyParamBound>> {
-> Option<TyParamBounds> {
b.map(|bounds| folder.fold_bounds(bounds))
}

Expand Down
15 changes: 7 additions & 8 deletions src/librustc_front/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(),
})
}

Expand Down Expand Up @@ -267,10 +266,10 @@ pub struct AngleBracketedParameterData {
/// The lifetime parameters for this path segment.
pub lifetimes: Vec<Lifetime>,
/// The type parameters for this path segment, if present.
pub types: OwnedSlice<P<Ty>>,
pub types: P<[P<Ty>]>,
/// Bindings (equality constraints) on associated types, if present.
/// E.g., `Foo<A=Bar>`.
pub bindings: OwnedSlice<TypeBinding>,
pub bindings: P<[TypeBinding]>,
}

impl AngleBracketedParameterData {
Expand Down Expand Up @@ -310,7 +309,7 @@ pub enum TraitBoundModifier {
Maybe,
}

pub type TyParamBounds = OwnedSlice<TyParamBound>;
pub type TyParamBounds = P<[TyParamBound]>;

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct TyParam {
Expand All @@ -326,7 +325,7 @@ pub struct TyParam {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct Generics {
pub lifetimes: Vec<LifetimeDef>,
pub ty_params: OwnedSlice<TyParam>,
pub ty_params: P<[TyParam]>,
pub where_clause: WhereClause,
}

Expand Down Expand Up @@ -369,7 +368,7 @@ pub struct WhereBoundPredicate {
/// The type being bounded
pub bounded_ty: P<Ty>,
/// Trait and lifetime bounds (`Clone+Send+'static`)
pub bounds: OwnedSlice<TyParamBound>,
pub bounds: TyParamBounds,
}

/// A lifetime predicate, e.g. `'a: 'b+'c`
Expand Down
13 changes: 6 additions & 7 deletions src/librustc_front/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -430,8 +429,8 @@ pub fn lower_ty_param(lctx: &LoweringContext, tp: &TyParam) -> hir::TyParam {
}

pub fn lower_ty_params(lctx: &LoweringContext,
tps: &OwnedSlice<TyParam>)
-> OwnedSlice<hir::TyParam> {
tps: &P<[TyParam]>)
-> P<[hir::TyParam]> {
tps.iter().map(|tp| lower_ty_param(lctx, tp)).collect()
}

Expand Down Expand Up @@ -583,8 +582,8 @@ pub fn lower_mt(lctx: &LoweringContext, mt: &MutTy) -> hir::MutTy {
}

pub fn lower_opt_bounds(lctx: &LoweringContext,
b: &Option<OwnedSlice<TyParamBound>>)
-> Option<OwnedSlice<hir::TyParamBound>> {
b: &Option<TyParamBounds>)
-> Option<hir::TyParamBounds> {
b.as_ref().map(|ref bounds| lower_bounds(lctx, bounds))
}

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_front/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_front/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F>(pat: &Pat, mut it: F) -> bool
where F: FnMut(&Pat) -> bool
Expand Down Expand Up @@ -336,7 +335,7 @@ pub fn is_path(e: P<Expr>) -> 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(),
Expand All @@ -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(),
}),
}),
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_trans/save/dump_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use std::fs::File;
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;
Expand Down Expand Up @@ -572,7 +571,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
fn process_trait(&mut self,
item: &ast::Item,
generics: &ast::Generics,
trait_refs: &OwnedSlice<ast::TyParamBound>,
trait_refs: &ast::TyParamBounds,
methods: &[P<ast::TraitItem>]) {
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
let val = self.span.snippet(item.span);
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -4907,7 +4906,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<hir::TyParam>,
tps: &P<[hir::TyParam]>,
ty: Ty<'tcx>) {
debug!("check_bounds_are_used(n_tps={}, ty={:?})",
tps.len(), ty);
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<T, U> Clean<U> for ty::Binder<T> where T: Clean<U> {
}
}

impl<T: Clean<U>, U> Clean<Vec<U>> for syntax::owned_slice::OwnedSlice<T> {
impl<T: Clean<U>, U> Clean<Vec<U>> for P<[T]> {
fn clean(&self, cx: &DocContext) -> Vec<U> {
self.iter().map(|x| x.clean(cx)).collect()
}
Expand Down
17 changes: 8 additions & 9 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
use parse::token;
use parse::lexer;
Expand Down Expand Up @@ -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(),
})
}

Expand Down Expand Up @@ -334,10 +333,10 @@ pub struct AngleBracketedParameterData {
/// The lifetime parameters for this path segment.
pub lifetimes: Vec<Lifetime>,
/// The type parameters for this path segment, if present.
pub types: OwnedSlice<P<Ty>>,
pub types: P<[P<Ty>]>,
/// Bindings (equality constraints) on associated types, if present.
/// E.g., `Foo<A=Bar>`.
pub bindings: OwnedSlice<P<TypeBinding>>,
pub bindings: P<[P<TypeBinding>]>,
}

impl AngleBracketedParameterData {
Expand Down Expand Up @@ -394,7 +393,7 @@ pub enum TraitBoundModifier {
Maybe,
}

pub type TyParamBounds = OwnedSlice<TyParamBound>;
pub type TyParamBounds = P<[TyParamBound]>;

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct TyParam {
Expand All @@ -410,7 +409,7 @@ pub struct TyParam {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
pub struct Generics {
pub lifetimes: Vec<LifetimeDef>,
pub ty_params: OwnedSlice<TyParam>,
pub ty_params: P<[TyParam]>,
pub where_clause: WhereClause,
}

Expand All @@ -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(),
Expand Down Expand Up @@ -466,7 +465,7 @@ pub struct WhereBoundPredicate {
/// The type being bounded
pub bounded_ty: P<Ty>,
/// Trait and lifetime bounds (`Clone+Send+'static`)
pub bounds: OwnedSlice<TyParamBound>,
pub bounds: TyParamBounds,
}

/// A lifetime predicate, e.g. `'a: 'b+'c`
Expand Down
Loading

0 comments on commit 0d298f9

Please sign in to comment.