Skip to content

Commit 9e953df

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 158a1bd + 6c87b19 commit 9e953df

File tree

33 files changed

+400
-413
lines changed

33 files changed

+400
-413
lines changed

src/librustc/middle/check_match.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
517517
ty::TyEnum(adt, _) | ty::TyStruct(adt, _) => {
518518
let v = adt.variant_of_ctor(ctor);
519519
if let VariantKind::Struct = v.kind() {
520-
let field_pats: Vec<_> = v.fields.iter()
520+
let field_pats: hir::HirVec<_> = v.fields.iter()
521521
.zip(pats)
522522
.filter(|&(_, ref pat)| pat.node != hir::PatWild)
523523
.map(|(field, pat)| Spanned {
@@ -540,14 +540,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
540540
ty::TyArray(_, n) => match ctor {
541541
&Single => {
542542
assert_eq!(pats_len, n);
543-
hir::PatVec(pats.collect(), None, vec!())
543+
hir::PatVec(pats.collect(), None, hir::HirVec::new())
544544
},
545545
_ => unreachable!()
546546
},
547547
ty::TySlice(_) => match ctor {
548548
&Slice(n) => {
549549
assert_eq!(pats_len, n);
550-
hir::PatVec(pats.collect(), None, vec!())
550+
hir::PatVec(pats.collect(), None, hir::HirVec::new())
551551
},
552552
_ => unreachable!()
553553
},
@@ -562,7 +562,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
562562

563563
ty::TyArray(_, len) => {
564564
assert_eq!(pats_len, len);
565-
hir::PatVec(pats.collect(), None, vec![])
565+
hir::PatVec(pats.collect(), None, hir::HirVec::new())
566566
}
567567

568568
_ => {

src/librustc/middle/const_eval.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,14 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr, span: Span) -> P<hir::Pat>
357357

358358
hir::ExprVec(ref exprs) => {
359359
let pats = exprs.iter().map(|expr| const_expr_to_pat(tcx, &**expr, span)).collect();
360-
hir::PatVec(pats, None, vec![])
360+
hir::PatVec(pats, None, hir::HirVec::new())
361361
}
362362

363363
hir::ExprPath(_, ref path) => {
364364
let opt_def = tcx.def_map.borrow().get(&expr.id).map(|d| d.full_def());
365365
match opt_def {
366366
Some(def::DefStruct(..)) =>
367-
hir::PatStruct(path.clone(), vec![], false),
367+
hir::PatStruct(path.clone(), hir::HirVec::new(), false),
368368
Some(def::DefVariant(..)) =>
369369
hir::PatEnum(path.clone(), None),
370370
_ => {

src/librustc/middle/expr_use_visitor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
324324
self.delegate.consume(consume_id, consume_span, cmt, mode);
325325
}
326326

327-
fn consume_exprs(&mut self, exprs: &Vec<P<hir::Expr>>) {
327+
fn consume_exprs(&mut self, exprs: &[P<hir::Expr>]) {
328328
for expr in exprs {
329329
self.consume_expr(&**expr);
330330
}
@@ -651,7 +651,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
651651

652652
fn walk_struct_expr(&mut self,
653653
_expr: &hir::Expr,
654-
fields: &Vec<hir::Field>,
654+
fields: &[hir::Field],
655655
opt_with: &Option<P<hir::Expr>>) {
656656
// Consume the expressions supplying values for each field.
657657
for field in fields {
@@ -697,7 +697,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
697697
self.walk_expr(with_expr);
698698

699699
fn contains_field_named(field: ty::FieldDef,
700-
fields: &Vec<hir::Field>)
700+
fields: &[hir::Field])
701701
-> bool
702702
{
703703
fields.iter().any(

src/librustc/middle/infer/error_reporting.rs

+11-12
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,13 +1248,13 @@ 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();
12561255
for lt in add {
12571256
lifetimes.push(hir::LifetimeDef { lifetime: *lt,
1258-
bounds: Vec::new() });
1257+
bounds: hir::HirVec::new() });
12591258
}
12601259
for lt in &generics.lifetimes {
12611260
if keep.contains(&lt.lifetime.name) ||
@@ -1264,7 +1263,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12641263
}
12651264
}
12661265
hir::Generics {
1267-
lifetimes: lifetimes,
1266+
lifetimes: lifetimes.into(),
12681267
ty_params: ty_params,
12691268
where_clause: where_clause,
12701269
}
@@ -1275,7 +1274,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12751274
lifetime: hir::Lifetime,
12761275
anon_nums: &HashSet<u32>,
12771276
region_names: &HashSet<ast::Name>)
1278-
-> Vec<hir::Arg> {
1277+
-> hir::HirVec<hir::Arg> {
12791278
let mut new_inputs = Vec::new();
12801279
for arg in inputs {
12811280
let new_ty = self.rebuild_arg_ty_or_output(&*arg.ty, lifetime,
@@ -1287,7 +1286,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
12871286
};
12881287
new_inputs.push(possibly_new_arg);
12891288
}
1290-
new_inputs
1289+
new_inputs.into()
12911290
}
12921291

12931292
fn rebuild_output(&self, ty: &hir::FunctionRetTy,
@@ -1514,7 +1513,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
15141513
}
15151514
});
15161515
hir::AngleBracketedParameters(hir::AngleBracketedParameterData {
1517-
lifetimes: new_lts,
1516+
lifetimes: new_lts.into(),
15181517
types: new_types,
15191518
bindings: new_bindings,
15201519
})
@@ -1530,7 +1529,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
15301529
hir::Path {
15311530
span: path.span,
15321531
global: path.global,
1533-
segments: new_segs
1532+
segments: new_segs.into()
15341533
}
15351534
}
15361535
}

src/librustc/middle/resolve_lifetime.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ struct LifetimeContext<'a> {
7979
enum ScopeChain<'a> {
8080
/// EarlyScope(i, ['a, 'b, ...], s) extends s with early-bound
8181
/// lifetimes, assigning indexes 'a => i, 'b => i+1, ... etc.
82-
EarlyScope(subst::ParamSpace, &'a Vec<hir::LifetimeDef>, Scope<'a>),
82+
EarlyScope(subst::ParamSpace, &'a [hir::LifetimeDef], Scope<'a>),
8383
/// LateScope(['a, 'b, ...], s) extends s with late-bound
8484
/// lifetimes introduced by the declaration binder_id.
85-
LateScope(&'a Vec<hir::LifetimeDef>, Scope<'a>),
85+
LateScope(&'a [hir::LifetimeDef], Scope<'a>),
8686

8787
/// lifetimes introduced by a fn are scoped to the call-site for that fn.
8888
FnScope { fn_id: ast::NodeId, body_id: ast::NodeId, s: Scope<'a> },
@@ -206,7 +206,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
206206
// a trait ref, which introduces a binding scope.
207207
match self.def_map.get(&ty.id).map(|d| (d.base_def, d.depth)) {
208208
Some((def::DefTrait(..), 0)) => {
209-
self.with(LateScope(&Vec::new(), self.scope), |_, this| {
209+
self.with(LateScope(&[], self.scope), |_, this| {
210210
this.visit_path(path, ty.id);
211211
});
212212
}
@@ -661,7 +661,7 @@ impl<'a> LifetimeContext<'a> {
661661
lifetime_ref.name);
662662
}
663663

664-
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<hir::LifetimeDef>) {
664+
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &[hir::LifetimeDef]) {
665665
for i in 0..lifetimes.len() {
666666
let lifetime_i = &lifetimes[i];
667667

@@ -753,7 +753,7 @@ impl<'a> LifetimeContext<'a> {
753753
}
754754
}
755755

756-
fn search_lifetimes<'a>(lifetimes: &'a Vec<hir::LifetimeDef>,
756+
fn search_lifetimes<'a>(lifetimes: &'a [hir::LifetimeDef],
757757
lifetime_ref: &hir::Lifetime)
758758
-> Option<(u32, &'a hir::Lifetime)> {
759759
for (i, lifetime_decl) in lifetimes.iter().enumerate() {

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct Annotator<'a, 'tcx: 'a> {
8282
impl<'a, 'tcx: 'a> Annotator<'a, 'tcx> {
8383
// Determine the stability for a node based on its attributes and inherited
8484
// stability. The stability is recorded in the index and used as the parent.
85-
fn annotate<F>(&mut self, id: NodeId, attrs: &Vec<Attribute>,
85+
fn annotate<F>(&mut self, id: NodeId, attrs: &[Attribute],
8686
item_sp: Span, kind: AnnotationKind, visit_children: F)
8787
where F: FnOnce(&mut Annotator)
8888
{

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

+20-19
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;
@@ -35,7 +34,7 @@ pub trait Folder : Sized {
3534
noop_fold_crate(c, self)
3635
}
3736

38-
fn fold_meta_items(&mut self, meta_items: Vec<P<MetaItem>>) -> Vec<P<MetaItem>> {
37+
fn fold_meta_items(&mut self, meta_items: HirVec<P<MetaItem>>) -> HirVec<P<MetaItem>> {
3938
noop_fold_meta_items(meta_items, self)
4039
}
4140

@@ -199,19 +198,19 @@ pub trait Folder : Sized {
199198
noop_fold_variant_data(vdata, self)
200199
}
201200

202-
fn fold_lifetimes(&mut self, lts: Vec<Lifetime>) -> Vec<Lifetime> {
201+
fn fold_lifetimes(&mut self, lts: HirVec<Lifetime>) -> HirVec<Lifetime> {
203202
noop_fold_lifetimes(lts, self)
204203
}
205204

206-
fn fold_lifetime_defs(&mut self, lts: Vec<LifetimeDef>) -> Vec<LifetimeDef> {
205+
fn fold_lifetime_defs(&mut self, lts: HirVec<LifetimeDef>) -> HirVec<LifetimeDef> {
207206
noop_fold_lifetime_defs(lts, self)
208207
}
209208

210209
fn fold_ty_param(&mut self, tp: TyParam) -> TyParam {
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

@@ -264,9 +263,9 @@ pub trait Folder : Sized {
264263
}
265264
}
266265

267-
pub fn noop_fold_meta_items<T: Folder>(meta_items: Vec<P<MetaItem>>,
266+
pub fn noop_fold_meta_items<T: Folder>(meta_items: HirVec<P<MetaItem>>,
268267
fld: &mut T)
269-
-> Vec<P<MetaItem>> {
268+
-> HirVec<P<MetaItem>> {
270269
meta_items.move_map(|x| fld.fold_meta_item(x))
271270
}
272271

@@ -305,7 +304,7 @@ pub fn noop_fold_view_path<T: Folder>(view_path: P<ViewPath>, fld: &mut T) -> P<
305304
})
306305
}
307306

308-
pub fn fold_attrs<T: Folder>(attrs: Vec<Attribute>, fld: &mut T) -> Vec<Attribute> {
307+
pub fn fold_attrs<T: Folder>(attrs: HirVec<Attribute>, fld: &mut T) -> HirVec<Attribute> {
309308
attrs.move_flat_map(|x| fld.fold_attribute(x))
310309
}
311310

@@ -478,7 +477,7 @@ pub fn noop_fold_local<T: Folder>(l: P<Local>, fld: &mut T) -> P<Local> {
478477
pat: fld.fold_pat(pat),
479478
init: init.map(|e| fld.fold_expr(e)),
480479
span: fld.new_span(span),
481-
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs, fld)),
480+
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs.into(), fld).into()),
482481
}
483482
})
484483
}
@@ -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

@@ -597,11 +596,13 @@ pub fn noop_fold_lifetime_def<T: Folder>(l: LifetimeDef, fld: &mut T) -> Lifetim
597596
}
598597
}
599598

600-
pub fn noop_fold_lifetimes<T: Folder>(lts: Vec<Lifetime>, fld: &mut T) -> Vec<Lifetime> {
599+
pub fn noop_fold_lifetimes<T: Folder>(lts: HirVec<Lifetime>, fld: &mut T) -> HirVec<Lifetime> {
601600
lts.move_map(|l| fld.fold_lifetime(l))
602601
}
603602

604-
pub fn noop_fold_lifetime_defs<T: Folder>(lts: Vec<LifetimeDef>, fld: &mut T) -> Vec<LifetimeDef> {
603+
pub fn noop_fold_lifetime_defs<T: Folder>(lts: HirVec<LifetimeDef>,
604+
fld: &mut T)
605+
-> HirVec<LifetimeDef> {
605606
lts.move_map(|l| fld.fold_lifetime_def(l))
606607
}
607608

@@ -726,9 +727,9 @@ pub fn noop_fold_mt<T: Folder>(MutTy { ty, mutbl }: MutTy, folder: &mut T) -> Mu
726727
}
727728
}
728729

729-
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<OwnedSlice<TyParamBound>>,
730+
pub fn noop_fold_opt_bounds<T: Folder>(b: Option<TyParamBounds>,
730731
folder: &mut T)
731-
-> Option<OwnedSlice<TyParamBound>> {
732+
-> Option<TyParamBounds> {
732733
b.map(|bounds| folder.fold_bounds(bounds))
733734
}
734735

@@ -1140,7 +1141,7 @@ pub fn noop_fold_expr<T: Folder>(Expr { id, node, span, attrs }: Expr, folder: &
11401141
}
11411142
},
11421143
span: folder.new_span(span),
1143-
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs, folder)),
1144+
attrs: attrs.map_thin_attrs(|attrs| fold_attrs(attrs.into(), folder).into()),
11441145
}
11451146
}
11461147

0 commit comments

Comments
 (0)