Skip to content

Commit c629b33

Browse files
committed
Rollup merge of rust-lang#30420 - petrochenkov:owned2, r=nrc
Part of rust-lang#30095 not causing mysterious segfaults. r? @nrc
2 parents f2cdf30 + 458e86a commit c629b33

File tree

23 files changed

+186
-229
lines changed

23 files changed

+186
-229
lines changed

src/librustc/middle/infer/error_reporting.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ use std::cell::{Cell, RefCell};
9090
use std::char::from_u32;
9191
use std::fmt;
9292
use syntax::ast;
93-
use syntax::owned_slice::OwnedSlice;
9493
use syntax::codemap::{self, Pos, Span};
9594
use syntax::parse::token;
9695
use syntax::ptr::P;
@@ -1154,10 +1153,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
11541153
}
11551154

11561155
fn rebuild_ty_params(&self,
1157-
ty_params: OwnedSlice<hir::TyParam>,
1156+
ty_params: P<[hir::TyParam]>,
11581157
lifetime: hir::Lifetime,
11591158
region_names: &HashSet<ast::Name>)
1160-
-> OwnedSlice<hir::TyParam> {
1159+
-> P<[hir::TyParam]> {
11611160
ty_params.map(|ty_param| {
11621161
let bounds = self.rebuild_ty_param_bounds(ty_param.bounds.clone(),
11631162
lifetime,
@@ -1173,10 +1172,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
11731172
}
11741173

11751174
fn rebuild_ty_param_bounds(&self,
1176-
ty_param_bounds: OwnedSlice<hir::TyParamBound>,
1175+
ty_param_bounds: hir::TyParamBounds,
11771176
lifetime: hir::Lifetime,
11781177
region_names: &HashSet<ast::Name>)
1179-
-> OwnedSlice<hir::TyParamBound> {
1178+
-> hir::TyParamBounds {
11801179
ty_param_bounds.map(|tpb| {
11811180
match tpb {
11821181
&hir::RegionTyParamBound(lt) => {
@@ -1249,7 +1248,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12491248
add: &Vec<hir::Lifetime>,
12501249
keep: &HashSet<ast::Name>,
12511250
remove: &HashSet<ast::Name>,
1252-
ty_params: OwnedSlice<hir::TyParam>,
1251+
ty_params: P<[hir::TyParam]>,
12531252
where_clause: hir::WhereClause)
12541253
-> hir::Generics {
12551254
let mut lifetimes = Vec::new();

src/librustc/middle/ty/structural_impls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use middle::ty::fold::{TypeFoldable, TypeFolder};
1616

1717
use std::rc::Rc;
1818
use syntax::abi;
19-
use syntax::owned_slice::OwnedSlice;
19+
use syntax::ptr::P;
2020

2121
use rustc_front::hir;
2222

@@ -555,8 +555,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
555555
}
556556
}
557557

558-
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for OwnedSlice<T> {
559-
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> OwnedSlice<T> {
558+
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for P<[T]> {
559+
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> P<[T]> {
560560
self.iter().map(|t| t.fold_with(folder)).collect()
561561
}
562562
}

src/librustc_front/fold.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use syntax::ast::{MetaWord, MetaList, MetaNameValue};
1717
use syntax::attr::ThinAttributesExt;
1818
use hir;
1919
use syntax::codemap::{respan, Span, Spanned};
20-
use syntax::owned_slice::OwnedSlice;
2120
use syntax::ptr::P;
2221
use syntax::parse::token;
2322
use syntax::util::move_map::MoveMap;
@@ -211,7 +210,7 @@ pub trait Folder : Sized {
211210
noop_fold_ty_param(tp, self)
212211
}
213212

214-
fn fold_ty_params(&mut self, tps: OwnedSlice<TyParam>) -> OwnedSlice<TyParam> {
213+
fn fold_ty_params(&mut self, tps: P<[TyParam]>) -> P<[TyParam]> {
215214
noop_fold_ty_params(tps, self)
216215
}
217216

@@ -220,12 +219,12 @@ pub trait Folder : Sized {
220219
}
221220

222221
fn fold_opt_bounds(&mut self,
223-
b: Option<OwnedSlice<TyParamBound>>)
224-
-> Option<OwnedSlice<TyParamBound>> {
222+
b: Option<TyParamBounds>)
223+
-> Option<TyParamBounds> {
225224
noop_fold_opt_bounds(b, self)
226225
}
227226

228-
fn fold_bounds(&mut self, b: OwnedSlice<TyParamBound>) -> OwnedSlice<TyParamBound> {
227+
fn fold_bounds(&mut self, b: TyParamBounds) -> TyParamBounds {
229228
noop_fold_bounds(b, self)
230229
}
231230

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

579-
pub fn noop_fold_ty_params<T: Folder>(tps: OwnedSlice<TyParam>,
578+
pub fn noop_fold_ty_params<T: Folder>(tps: P<[TyParam]>,
580579
fld: &mut T)
581-
-> OwnedSlice<TyParam> {
580+
-> P<[TyParam]> {
582581
tps.move_map(|tp| fld.fold_ty_param(tp))
583582
}
584583

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

729-
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<OwnedSlice<TyParamBound>>,
728+
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<TyParamBounds>,
730729
folder: &mut T)
731-
-> Option<OwnedSlice<TyParamBound>> {
730+
-> Option<TyParamBounds> {
732731
b.map(|bounds| folder.fold_bounds(bounds))
733732
}
734733

src/librustc_front/hir.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use syntax::abi::Abi;
4242
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect};
4343
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, CrateConfig};
4444
use syntax::attr::ThinAttributes;
45-
use syntax::owned_slice::OwnedSlice;
4645
use syntax::parse::token::InternedString;
4746
use syntax::ptr::P;
4847

@@ -193,8 +192,8 @@ impl PathParameters {
193192
pub fn none() -> PathParameters {
194193
AngleBracketedParameters(AngleBracketedParameterData {
195194
lifetimes: Vec::new(),
196-
types: OwnedSlice::empty(),
197-
bindings: OwnedSlice::empty(),
195+
types: P::empty(),
196+
bindings: P::empty(),
198197
})
199198
}
200199

@@ -267,10 +266,10 @@ pub struct AngleBracketedParameterData {
267266
/// The lifetime parameters for this path segment.
268267
pub lifetimes: Vec<Lifetime>,
269268
/// The type parameters for this path segment, if present.
270-
pub types: OwnedSlice<P<Ty>>,
269+
pub types: P<[P<Ty>]>,
271270
/// Bindings (equality constraints) on associated types, if present.
272271
/// E.g., `Foo<A=Bar>`.
273-
pub bindings: OwnedSlice<TypeBinding>,
272+
pub bindings: P<[TypeBinding]>,
274273
}
275274

276275
impl AngleBracketedParameterData {
@@ -310,7 +309,7 @@ pub enum TraitBoundModifier {
310309
Maybe,
311310
}
312311

313-
pub type TyParamBounds = OwnedSlice<TyParamBound>;
312+
pub type TyParamBounds = P<[TyParamBound]>;
314313

315314
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
316315
pub struct TyParam {
@@ -326,7 +325,7 @@ pub struct TyParam {
326325
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
327326
pub struct Generics {
328327
pub lifetimes: Vec<LifetimeDef>,
329-
pub ty_params: OwnedSlice<TyParam>,
328+
pub ty_params: P<[TyParam]>,
330329
pub where_clause: WhereClause,
331330
}
332331

@@ -369,7 +368,7 @@ pub struct WhereBoundPredicate {
369368
/// The type being bounded
370369
pub bounded_ty: P<Ty>,
371370
/// Trait and lifetime bounds (`Clone+Send+'static`)
372-
pub bounds: OwnedSlice<TyParamBound>,
371+
pub bounds: TyParamBounds,
373372
}
374373

375374
/// A lifetime predicate, e.g. `'a: 'b+'c`

src/librustc_front/lowering.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ use syntax::attr::{ThinAttributes, ThinAttributesExt};
7070
use syntax::ext::mtwt;
7171
use syntax::ptr::P;
7272
use syntax::codemap::{respan, Spanned, Span};
73-
use syntax::owned_slice::OwnedSlice;
7473
use syntax::parse::token;
7574
use syntax::std_inject;
7675
use syntax::visit::{self, Visitor};
@@ -430,8 +429,8 @@ pub fn lower_ty_param(lctx: &LoweringContext, tp: &TyParam) -> hir::TyParam {
430429
}
431430

432431
pub fn lower_ty_params(lctx: &LoweringContext,
433-
tps: &OwnedSlice<TyParam>)
434-
-> OwnedSlice<hir::TyParam> {
432+
tps: &P<[TyParam]>)
433+
-> P<[hir::TyParam]> {
435434
tps.iter().map(|tp| lower_ty_param(lctx, tp)).collect()
436435
}
437436

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

585584
pub fn lower_opt_bounds(lctx: &LoweringContext,
586-
b: &Option<OwnedSlice<TyParamBound>>)
587-
-> Option<OwnedSlice<hir::TyParamBound>> {
585+
b: &Option<TyParamBounds>)
586+
-> Option<hir::TyParamBounds> {
588587
b.as_ref().map(|ref bounds| lower_bounds(lctx, bounds))
589588
}
590589

@@ -1795,8 +1794,8 @@ fn path_all(sp: Span,
17951794
identifier: last_identifier,
17961795
parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
17971796
lifetimes: lifetimes,
1798-
types: OwnedSlice::from_vec(types),
1799-
bindings: OwnedSlice::from_vec(bindings),
1797+
types: P::from_vec(types),
1798+
bindings: P::from_vec(bindings),
18001799
}),
18011800
});
18021801
hir::Path {

src/librustc_front/print/pprust.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub use self::AnnNode::*;
1212

1313
use syntax::abi;
1414
use syntax::ast;
15-
use syntax::owned_slice::OwnedSlice;
1615
use syntax::codemap::{self, CodeMap, BytePos, Spanned};
1716
use syntax::diagnostic;
1817
use syntax::parse::token::{self, BinOpToken};
@@ -519,7 +518,7 @@ impl<'a> State<'a> {
519518
hir::TyBareFn(ref f) => {
520519
let generics = hir::Generics {
521520
lifetimes: f.lifetimes.clone(),
522-
ty_params: OwnedSlice::empty(),
521+
ty_params: P::empty(),
523522
where_clause: hir::WhereClause {
524523
id: ast::DUMMY_NODE_ID,
525524
predicates: Vec::new(),
@@ -2258,7 +2257,7 @@ impl<'a> State<'a> {
22582257
}
22592258
let generics = hir::Generics {
22602259
lifetimes: Vec::new(),
2261-
ty_params: OwnedSlice::empty(),
2260+
ty_params: P::empty(),
22622261
where_clause: hir::WhereClause {
22632262
id: ast::DUMMY_NODE_ID,
22642263
predicates: Vec::new(),

src/librustc_front/util.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use syntax::ast_util;
1515
use syntax::ast::{Name, NodeId, DUMMY_NODE_ID};
1616
use syntax::codemap::Span;
1717
use syntax::ptr::P;
18-
use syntax::owned_slice::OwnedSlice;
1918

2019
pub fn walk_pat<F>(pat: &Pat, mut it: F) -> bool
2120
where F: FnMut(&Pat) -> bool
@@ -336,7 +335,7 @@ pub fn is_path(e: P<Expr>) -> bool {
336335
pub fn empty_generics() -> Generics {
337336
Generics {
338337
lifetimes: Vec::new(),
339-
ty_params: OwnedSlice::empty(),
338+
ty_params: P::empty(),
340339
where_clause: WhereClause {
341340
id: DUMMY_NODE_ID,
342341
predicates: Vec::new(),
@@ -354,8 +353,8 @@ pub fn ident_to_path(s: Span, ident: Ident) -> Path {
354353
identifier: ident,
355354
parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
356355
lifetimes: Vec::new(),
357-
types: OwnedSlice::empty(),
358-
bindings: OwnedSlice::empty(),
356+
types: P::empty(),
357+
bindings: P::empty(),
359358
}),
360359
}),
361360
}

src/librustc_trans/save/dump_csv.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use std::path::Path;
4242
use syntax::ast::{self, NodeId};
4343
use syntax::codemap::*;
4444
use syntax::parse::token::{self, keywords};
45-
use syntax::owned_slice::OwnedSlice;
4645
use syntax::visit::{self, Visitor};
4746
use syntax::print::pprust::{path_to_string, ty_to_string};
4847
use syntax::ptr::P;
@@ -574,7 +573,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
574573
fn process_trait(&mut self,
575574
item: &ast::Item,
576575
generics: &ast::Generics,
577-
trait_refs: &OwnedSlice<ast::TyParamBound>,
576+
trait_refs: &ast::TyParamBounds,
578577
methods: &[P<ast::TraitItem>]) {
579578
let qualname = format!("::{}", self.tcx.map.path_to_string(item.id));
580579
let val = self.span.snippet(item.span);

src/librustc_typeck/check/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ use syntax::ast;
119119
use syntax::attr;
120120
use syntax::attr::AttrMetaMethods;
121121
use syntax::codemap::{self, Span, Spanned};
122-
use syntax::owned_slice::OwnedSlice;
123122
use syntax::parse::token::{self, InternedString};
124123
use syntax::ptr::P;
125124
use syntax::util::lev_distance::lev_distance;
@@ -4910,7 +4909,7 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &hir::Block) -> bool {
49104909
}
49114910

49124911
pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
4913-
tps: &OwnedSlice<hir::TyParam>,
4912+
tps: &P<[hir::TyParam]>,
49144913
ty: Ty<'tcx>) {
49154914
debug!("check_bounds_are_used(n_tps={}, ty={:?})",
49164915
tps.len(), ty);

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<T, U> Clean<U> for ty::Binder<T> where T: Clean<U> {
112112
}
113113
}
114114

115-
impl<T: Clean<U>, U> Clean<Vec<U>> for syntax::owned_slice::OwnedSlice<T> {
115+
impl<T: Clean<U>, U> Clean<Vec<U>> for P<[T]> {
116116
fn clean(&self, cx: &DocContext) -> Vec<U> {
117117
self.iter().map(|x| x.clean(cx)).collect()
118118
}

src/libsyntax/ast.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use codemap::{Span, Spanned, DUMMY_SP, ExpnId};
5050
use abi::Abi;
5151
use ext::base;
5252
use ext::tt::macro_parser;
53-
use owned_slice::OwnedSlice;
5453
use parse::token::{InternedString, str_to_ident};
5554
use parse::token;
5655
use parse::lexer;
@@ -261,8 +260,8 @@ impl PathParameters {
261260
pub fn none() -> PathParameters {
262261
AngleBracketedParameters(AngleBracketedParameterData {
263262
lifetimes: Vec::new(),
264-
types: OwnedSlice::empty(),
265-
bindings: OwnedSlice::empty(),
263+
types: P::empty(),
264+
bindings: P::empty(),
266265
})
267266
}
268267

@@ -334,10 +333,10 @@ pub struct AngleBracketedParameterData {
334333
/// The lifetime parameters for this path segment.
335334
pub lifetimes: Vec<Lifetime>,
336335
/// The type parameters for this path segment, if present.
337-
pub types: OwnedSlice<P<Ty>>,
336+
pub types: P<[P<Ty>]>,
338337
/// Bindings (equality constraints) on associated types, if present.
339338
/// E.g., `Foo<A=Bar>`.
340-
pub bindings: OwnedSlice<P<TypeBinding>>,
339+
pub bindings: P<[P<TypeBinding>]>,
341340
}
342341

343342
impl AngleBracketedParameterData {
@@ -394,7 +393,7 @@ pub enum TraitBoundModifier {
394393
Maybe,
395394
}
396395

397-
pub type TyParamBounds = OwnedSlice<TyParamBound>;
396+
pub type TyParamBounds = P<[TyParamBound]>;
398397

399398
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
400399
pub struct TyParam {
@@ -410,7 +409,7 @@ pub struct TyParam {
410409
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
411410
pub struct Generics {
412411
pub lifetimes: Vec<LifetimeDef>,
413-
pub ty_params: OwnedSlice<TyParam>,
412+
pub ty_params: P<[TyParam]>,
414413
pub where_clause: WhereClause,
415414
}
416415

@@ -430,7 +429,7 @@ impl Default for Generics {
430429
fn default() -> Generics {
431430
Generics {
432431
lifetimes: Vec::new(),
433-
ty_params: OwnedSlice::empty(),
432+
ty_params: P::empty(),
434433
where_clause: WhereClause {
435434
id: DUMMY_NODE_ID,
436435
predicates: Vec::new(),
@@ -466,7 +465,7 @@ pub struct WhereBoundPredicate {
466465
/// The type being bounded
467466
pub bounded_ty: P<Ty>,
468467
/// Trait and lifetime bounds (`Clone+Send+'static`)
469-
pub bounds: OwnedSlice<TyParamBound>,
468+
pub bounds: TyParamBounds,
470469
}
471470

472471
/// A lifetime predicate, e.g. `'a: 'b+'c`

0 commit comments

Comments
 (0)