Skip to content

Commit e33676b

Browse files
committed
Migrate all users of opt_vec to owned_slice, delete opt_vec.
syntax::opt_vec is now entirely unused, and so can go.
1 parent 0384952 commit e33676b

35 files changed

+162
-340
lines changed

src/librustc/front/std_inject.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use syntax::codemap::DUMMY_SP;
1818
use syntax::codemap;
1919
use syntax::fold::Folder;
2020
use syntax::fold;
21-
use syntax::opt_vec;
21+
use syntax::owned_slice::OwnedSlice;
2222
use syntax::parse::token::InternedString;
2323
use syntax::parse::token;
2424
use syntax::util::small_vector::SmallVector;
@@ -164,12 +164,12 @@ impl<'a> fold::Folder for PreludeInjector<'a> {
164164
ast::PathSegment {
165165
identifier: token::str_to_ident("std"),
166166
lifetimes: Vec::new(),
167-
types: opt_vec::Empty,
167+
types: OwnedSlice::empty(),
168168
},
169169
ast::PathSegment {
170170
identifier: token::str_to_ident("prelude"),
171171
lifetimes: Vec::new(),
172-
types: opt_vec::Empty,
172+
types: OwnedSlice::empty(),
173173
}),
174174
};
175175

src/librustc/front/test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use syntax::ext::base::ExtCtxt;
3131
use syntax::ext::expand::ExpansionConfig;
3232
use syntax::fold::Folder;
3333
use syntax::fold;
34-
use syntax::opt_vec;
34+
use syntax::owned_slice::OwnedSlice;
3535
use syntax::parse::token::InternedString;
3636
use syntax::parse::token;
3737
use syntax::print::pprust;
@@ -377,7 +377,7 @@ fn path_node(ids: Vec<ast::Ident> ) -> ast::Path {
377377
segments: ids.move_iter().map(|identifier| ast::PathSegment {
378378
identifier: identifier,
379379
lifetimes: Vec::new(),
380-
types: opt_vec::Empty,
380+
types: OwnedSlice::empty(),
381381
}).collect()
382382
}
383383
}
@@ -389,7 +389,7 @@ fn path_node_global(ids: Vec<ast::Ident> ) -> ast::Path {
389389
segments: ids.move_iter().map(|identifier| ast::PathSegment {
390390
identifier: identifier,
391391
lifetimes: Vec::new(),
392-
types: opt_vec::Empty,
392+
types: OwnedSlice::empty(),
393393
}).collect()
394394
}
395395
}

src/librustc/metadata/tydecode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use syntax::abi::AbiSet;
2424
use syntax::abi;
2525
use syntax::ast;
2626
use syntax::ast::*;
27-
use syntax::opt_vec;
27+
use syntax::owned_slice::OwnedSlice;
2828
use syntax::parse::token;
2929

3030
// Compact string representation for ty::t values. API ty_str &
@@ -198,7 +198,7 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> ty::RegionSubsts {
198198
regions.push(r);
199199
}
200200
assert_eq!(next(st), '.');
201-
ty::NonerasedRegions(opt_vec::from(regions))
201+
ty::NonerasedRegions(OwnedSlice::from_vec(regions))
202202
}
203203
_ => fail!("parse_bound_region: bad input")
204204
}

src/librustc/middle/kind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use util::ppaux::UserString;
1919
use syntax::ast::*;
2020
use syntax::attr;
2121
use syntax::codemap::Span;
22-
use syntax::opt_vec;
22+
use syntax::owned_slice::OwnedSlice;
2323
use syntax::print::pprust::expr_to_str;
2424
use syntax::{visit,ast_util};
2525
use syntax::visit::Visitor;
@@ -92,7 +92,7 @@ fn check_struct_safe_for_destructor(cx: &mut Context,
9292
let struct_tpt = ty::lookup_item_type(cx.tcx, struct_did);
9393
if !struct_tpt.generics.has_type_params() {
9494
let struct_ty = ty::mk_struct(cx.tcx, struct_did, ty::substs {
95-
regions: ty::NonerasedRegions(opt_vec::Empty),
95+
regions: ty::NonerasedRegions(OwnedSlice::empty()),
9696
self_ty: None,
9797
tps: Vec::new()
9898
});

src/librustc/middle/privacy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use syntax::ast_util::{is_local, def_id_of_def, local_def};
2828
use syntax::attr;
2929
use syntax::codemap::Span;
3030
use syntax::parse::token;
31-
use syntax::opt_vec;
31+
use syntax::owned_slice::OwnedSlice;
3232
use syntax::visit;
3333
use syntax::visit::Visitor;
3434

@@ -842,7 +842,7 @@ impl<'a> Visitor<()> for PrivacyVisitor<'a> {
842842
let seg = ast::PathSegment {
843843
identifier: pid.node.name,
844844
lifetimes: Vec::new(),
845-
types: opt_vec::Empty,
845+
types: OwnedSlice::empty(),
846846
};
847847
let segs = vec!(seg);
848848
let path = ast::Path {

src/librustc/middle/resolve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use syntax::parse::token::special_idents;
2727
use syntax::parse::token;
2828
use syntax::print::pprust::path_to_str;
2929
use syntax::codemap::{Span, DUMMY_SP, Pos};
30-
use syntax::opt_vec::OptVec;
30+
use syntax::owned_slice::OwnedSlice;
3131
use syntax::visit;
3232
use syntax::visit::Visitor;
3333

@@ -3969,7 +3969,7 @@ impl<'a> Resolver<'a> {
39693969
}
39703970

39713971
fn resolve_type_parameters(&mut self,
3972-
type_parameters: &OptVec<TyParam>) {
3972+
type_parameters: &OwnedSlice<TyParam>) {
39733973
for type_parameter in type_parameters.iter() {
39743974
for bound in type_parameter.bounds.iter() {
39753975
self.resolve_type_parameter_bound(type_parameter.id, bound);

src/librustc/middle/resolve_lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use driver::session::Session;
2121
use util::nodemap::NodeMap;
2222
use syntax::ast;
2323
use syntax::codemap::Span;
24-
use syntax::opt_vec::OptVec;
24+
use syntax::owned_slice::OwnedSlice;
2525
use syntax::parse::token::special_idents;
2626
use syntax::parse::token;
2727
use syntax::print::pprust::{lifetime_to_str};
@@ -412,7 +412,7 @@ pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec<ast::Lifeti
412412
.collect()
413413
}
414414

415-
pub fn free_lifetimes(ty_params: &OptVec<ast::TyParam>) -> Vec<ast::Name> {
415+
pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>) -> Vec<ast::Name> {
416416
/*!
417417
* Gathers up and returns the names of any lifetimes that appear
418418
* free in `ty_params`. Of course, right now, all lifetimes appear

src/librustc/middle/subst.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use util::ppaux::Repr;
1717

1818
use std::rc::Rc;
1919
use syntax::codemap::Span;
20-
use syntax::opt_vec::OptVec;
20+
use syntax::owned_slice::OwnedSlice;
2121

2222
///////////////////////////////////////////////////////////////////////////
2323
// Public trait `Subst`
@@ -145,10 +145,10 @@ impl<T:Subst> Subst for Rc<T> {
145145
}
146146
}
147147

148-
impl<T:Subst> Subst for OptVec<T> {
148+
impl<T:Subst> Subst for OwnedSlice<T> {
149149
fn subst_spanned(&self, tcx: &ty::ctxt,
150150
substs: &ty::substs,
151-
span: Option<Span>) -> OptVec<T> {
151+
span: Option<Span>) -> OwnedSlice<T> {
152152
self.map(|t| t.subst_spanned(tcx, substs, span))
153153
}
154154
}

src/librustc/middle/trans/debuginfo.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ use std::ptr;
150150
use std::sync::atomics;
151151
use std::slice;
152152
use syntax::codemap::{Span, Pos};
153-
use syntax::{abi, ast, codemap, ast_util, ast_map, opt_vec};
153+
use syntax::{abi, ast, codemap, ast_util, ast_map};
154+
use syntax::owned_slice::OwnedSlice;
154155
use syntax::parse::token;
155156
use syntax::parse::token::special_idents;
156157

@@ -539,7 +540,7 @@ pub fn create_function_debug_context(cx: &CrateContext,
539540
return FunctionWithoutDebugInfo;
540541
}
541542

542-
let empty_generics = ast::Generics { lifetimes: Vec::new(), ty_params: opt_vec::Empty };
543+
let empty_generics = ast::Generics { lifetimes: Vec::new(), ty_params: OwnedSlice::empty() };
543544

544545
let fnitem = cx.tcx.map.get(fn_ast_id);
545546

src/librustc/middle/trans/type_of.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use util::ppaux::Repr;
2020
use middle::trans::type_::Type;
2121

2222
use syntax::ast;
23-
use syntax::opt_vec;
23+
use syntax::owned_slice::OwnedSlice;
2424

2525
pub fn arg_is_indirect(ccx: &CrateContext, arg_ty: ty::t) -> bool {
2626
!type_is_immediate(ccx, arg_ty)
@@ -324,7 +324,7 @@ pub fn llvm_type_name(cx: &CrateContext,
324324
an_enum => { "enum" }
325325
};
326326
let tstr = ppaux::parameterized(cx.tcx(), ty::item_path_str(cx.tcx(), did),
327-
&ty::NonerasedRegions(opt_vec::Empty),
327+
&ty::NonerasedRegions(OwnedSlice::empty()),
328328
tps, did, false);
329329
if did.krate == 0 {
330330
format!("{}.{}", name, tstr)

src/librustc/middle/ty.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ use syntax::codemap::Span;
5151
use syntax::parse::token;
5252
use syntax::parse::token::InternedString;
5353
use syntax::{ast, ast_map};
54-
use syntax::opt_vec::OptVec;
55-
use syntax::opt_vec;
54+
use syntax::owned_slice::OwnedSlice;
5655
use syntax::abi::AbiSet;
5756
use syntax;
5857
use collections::enum_set::{EnumSet, CLike};
@@ -192,8 +191,8 @@ pub enum ast_ty_to_ty_cache_entry {
192191
#[deriving(Clone, Eq, Decodable, Encodable)]
193192
pub struct ItemVariances {
194193
self_param: Option<Variance>,
195-
type_params: OptVec<Variance>,
196-
region_params: OptVec<Variance>
194+
type_params: OwnedSlice<Variance>,
195+
region_params: OwnedSlice<Variance>
197196
}
198197

199198
#[deriving(Clone, Eq, Decodable, Encodable, Show)]
@@ -646,7 +645,7 @@ pub enum BoundRegion {
646645
#[deriving(Clone, Eq, Hash)]
647646
pub enum RegionSubsts {
648647
ErasedRegions,
649-
NonerasedRegions(OptVec<ty::Region>)
648+
NonerasedRegions(OwnedSlice<ty::Region>)
650649
}
651650

652651
/**
@@ -4658,7 +4657,7 @@ pub fn visitor_object_ty(tcx: &ctxt,
46584657
Err(s) => { return Err(s); }
46594658
};
46604659
let substs = substs {
4661-
regions: ty::NonerasedRegions(opt_vec::Empty),
4660+
regions: ty::NonerasedRegions(OwnedSlice::empty()),
46624661
self_ty: None,
46634662
tps: Vec::new()
46644663
};
@@ -5092,7 +5091,7 @@ pub fn construct_parameter_environment(
50925091
let free_substs = substs {
50935092
self_ty: self_ty,
50945093
tps: type_params,
5095-
regions: ty::NonerasedRegions(opt_vec::from(region_params))
5094+
regions: ty::NonerasedRegions(OwnedSlice::from_vec(region_params))
50965095
};
50975096

50985097
//
@@ -5130,7 +5129,7 @@ impl substs {
51305129
substs {
51315130
self_ty: None,
51325131
tps: Vec::new(),
5133-
regions: NonerasedRegions(opt_vec::Empty)
5132+
regions: NonerasedRegions(OwnedSlice::empty())
51345133
}
51355134
}
51365135
}

src/librustc/middle/typeck/astconv.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ use util::ppaux::Repr;
6363
use syntax::abi::AbiSet;
6464
use syntax::{ast, ast_util};
6565
use syntax::codemap::Span;
66-
use syntax::opt_vec::OptVec;
67-
use syntax::opt_vec;
66+
use syntax::owned_slice::OwnedSlice;
6867
use syntax::print::pprust::{lifetime_to_str, path_to_str};
6968

7069
pub trait AstConv {
@@ -229,7 +228,7 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
229228
.collect();
230229

231230
let mut substs = substs {
232-
regions: ty::NonerasedRegions(opt_vec::from(regions)),
231+
regions: ty::NonerasedRegions(OwnedSlice::from_vec(regions)),
233232
self_ty: self_ty,
234233
tps: tps
235234
};
@@ -816,7 +815,7 @@ pub fn ty_of_closure<AC:AstConv,RS:RegionScope>(
816815
}
817816
}
818817

819-
fn conv_builtin_bounds(tcx: &ty::ctxt, ast_bounds: &Option<OptVec<ast::TyParamBound>>,
818+
fn conv_builtin_bounds(tcx: &ty::ctxt, ast_bounds: &Option<OwnedSlice<ast::TyParamBound>>,
820819
store: ty::TraitStore)
821820
-> ty::BuiltinBounds {
822821
//! Converts a list of bounds from the AST into a `BuiltinBounds`

src/librustc/middle/typeck/check/method.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ use syntax::ast::{MutMutable, MutImmutable};
104104
use syntax::ast;
105105
use syntax::codemap::Span;
106106
use syntax::parse::token;
107-
use syntax::opt_vec;
107+
use syntax::owned_slice::OwnedSlice;
108108

109109
#[deriving(Eq)]
110110
pub enum CheckTraitsFlag {
@@ -1120,7 +1120,7 @@ impl<'a> LookupContext<'a> {
11201120
let all_substs = substs {
11211121
tps: vec::append(candidate.rcvr_substs.tps.clone(),
11221122
m_substs.as_slice()),
1123-
regions: NonerasedRegions(opt_vec::from(all_regions)),
1123+
regions: NonerasedRegions(OwnedSlice::from_vec(all_regions)),
11241124
self_ty: candidate.rcvr_substs.self_ty,
11251125
};
11261126

src/librustc/middle/typeck/check/mod.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ use syntax::ast_util;
129129
use syntax::attr;
130130
use syntax::codemap::Span;
131131
use syntax::codemap;
132-
use syntax::opt_vec::OptVec;
133-
use syntax::opt_vec;
132+
use syntax::owned_slice::OwnedSlice;
134133
use syntax::parse::token;
135134
use syntax::print::pprust;
136135
use syntax::visit;
@@ -903,7 +902,7 @@ fn compare_impl_method(tcx: &ty::ctxt,
903902
impl_m.generics.type_param_defs().iter().enumerate().
904903
map(|(i,t)| ty::mk_param(tcx, i + impl_tps, t.def_id)).
905904
collect();
906-
let dummy_impl_regions: OptVec<ty::Region> =
905+
let dummy_impl_regions: OwnedSlice<ty::Region> =
907906
impl_generics.region_param_defs().iter().
908907
map(|l| ty::ReFree(ty::FreeRegion {
909908
scope_id: impl_m_body_id,
@@ -2631,7 +2630,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
26312630
}
26322631
};
26332632
let regions =
2634-
ty::NonerasedRegions(opt_vec::Empty);
2633+
ty::NonerasedRegions(OwnedSlice::empty());
26352634
let sty = ty::mk_struct(tcx,
26362635
gc_struct_id,
26372636
substs {
@@ -3706,7 +3705,7 @@ pub fn instantiate_path(fcx: &FnCtxt,
37063705
let num_expected_regions = tpt.generics.region_param_defs().len();
37073706
let num_supplied_regions = pth.segments.last().unwrap().lifetimes.len();
37083707
let regions = if num_expected_regions == num_supplied_regions {
3709-
opt_vec::from(pth.segments.last().unwrap().lifetimes.map(
3708+
OwnedSlice::from_vec(pth.segments.last().unwrap().lifetimes.map(
37103709
|l| ast_region_to_region(fcx.tcx(), l)))
37113710
} else {
37123711
if num_supplied_regions != 0 {
@@ -3971,7 +3970,7 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: ast::P<ast::Block>) -> bool
39713970

39723971
pub fn check_bounds_are_used(ccx: &CrateCtxt,
39733972
span: Span,
3974-
tps: &OptVec<ast::TyParam>,
3973+
tps: &OwnedSlice<ast::TyParam>,
39753974
ty: ty::t) {
39763975
debug!("check_bounds_are_used(n_tps={}, ty={})",
39773976
tps.len(), ppaux::ty_to_str(ccx.tcx, ty));
@@ -4087,7 +4086,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
40874086
Ok(did) => (1u, Vec::new(), ty::mk_struct(ccx.tcx, did, substs {
40884087
self_ty: None,
40894088
tps: Vec::new(),
4090-
regions: ty::NonerasedRegions(opt_vec::Empty)
4089+
regions: ty::NonerasedRegions(OwnedSlice::empty())
40914090
}) ),
40924091
Err(msg) => { tcx.sess.span_fatal(it.span, msg); }
40934092
}

0 commit comments

Comments
 (0)