fn as_slice<'a>(&'a self) -> &'a [T];
fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T];
fn iter<'a>(&'a self) -> Items<'a, T>;
- fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T>;
+ fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T>;
fn get<'a>(&'a self, index: uint) -> Option<&'a T>;
fn get_mut<'a>(&'a mut self, index: uint) -> Option<&'a mut T>;
}
slice.iter()
}
- fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> {
- self.as_mut_slice().mut_iter()
+ fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> {
+ self.as_mut_slice().iter_mut()
}
fn get<'a>(&'a self, index: uint) -> Option<&'a T> {
s
}
+ pub fn erase_regions(self) -> Substs {
+ let Substs { types: types, regions: _ } = self;
+ Substs { types: types, regions: ErasedRegions }
+ }
+
pub fn regions<'a>(&'a self) -> &'a VecPerParamSpace<ty::Region> {
/*!
* Since ErasedRegions are only to be used in trans, most of
}
}
+ fn new_internal(content: Vec<T>, type_limit: uint, self_limit: uint)
+ -> VecPerParamSpace<T>
+ {
+ VecPerParamSpace {
+ type_limit: type_limit,
+ self_limit: self_limit,
+ content: content,
+ }
+ }
+
pub fn sort(t: Vec<T>, space: |&T| -> ParamSpace) -> VecPerParamSpace<T> {
let mut result = VecPerParamSpace::empty();
- for t in t.move_iter() {
+ for t in t.into_iter() {
result.push(space(&t), t);
}
result
pub fn replace(&mut self, space: ParamSpace, elems: Vec<T>) {
// FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n).
self.truncate(space, 0);
- for t in elems.move_iter() {
+ for t in elems.into_iter() {
self.push(space, t);
}
}
pub fn get_mut_slice<'a>(&'a mut self, space: ParamSpace) -> &'a mut [T] {
let (start, limit) = self.limits(space);
- self.content.mut_slice(start, limit)
+ self.content.slice_mut(start, limit)
}
pub fn opt_get<'a>(&'a self,
}
pub fn map<U>(&self, pred: |&T| -> U) -> VecPerParamSpace<U> {
- // FIXME (#15418): this could avoid allocating the intermediate
- // Vec's, but note that the values of type_limit and self_limit
- // also need to be kept in sync during construction.
- VecPerParamSpace::new(
- self.get_slice(TypeSpace).iter().map(|p| pred(p)).collect(),
- self.get_slice(SelfSpace).iter().map(|p| pred(p)).collect(),
- self.get_slice(FnSpace).iter().map(|p| pred(p)).collect())
+ let result = self.iter().map(pred).collect();
+ VecPerParamSpace::new_internal(result,
+ self.type_limit,
+ self.self_limit)
+ }
+
+ pub fn map_move<U>(self, pred: |T| -> U) -> VecPerParamSpace<U> {
+ let (t, s, f) = self.split();
+ VecPerParamSpace::new(t.into_iter().map(|p| pred(p)).collect(),
+ s.into_iter().map(|p| pred(p)).collect(),
+ f.into_iter().map(|p| pred(p)).collect())
}
pub fn map_rev<U>(&self, pred: |&T| -> U) -> VecPerParamSpace<U> {
let t1 = match ty::get(t).sty {
ty::ty_param(p) => {
- check(self, p, t, self.substs.types.opt_get(p.space, p.idx))
+ check(self,
+ p,
+ t,
+ self.substs.types.opt_get(p.space, p.idx),
+ p.space,
+ p.idx)
}
_ => {
ty_fold::super_fold_ty(self, t)
fn check(this: &SubstFolder,
p: ty::ParamTy,
source_ty: ty::t,
- opt_ty: Option<&ty::t>)
+ opt_ty: Option<&ty::t>,
+ space: ParamSpace,
+ index: uint)
-> ty::t {
match opt_ty {
Some(t) => *t,
let span = this.span.unwrap_or(DUMMY_SP);
this.tcx().sess.span_bug(
span,
- format!("Type parameter `{}` ({}) out of range \
+ format!("Type parameter `{}` ({}/{}/{}) out of range \
when substituting (root type={})",
p.repr(this.tcx()),
source_ty.repr(this.tcx()),
+ space,
+ index,
this.root_ty.repr(this.tcx())).as_slice());
}
}