use ty::{self, Lift, Ty, TyCtxt};
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use rustc_data_structures::accumulate_vec::AccumulateVec;
+use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use std::rc::Rc;
use syntax::abi;
self.expected.visit_with(visitor) || self.found.visit_with(visitor)
}
}
+
+impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> TypeFoldable<'tcx> for IndexVec<I, T> {
+ fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
+ self.iter().map(|x| x.fold_with(folder)).collect()
+ }
+
+ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
+ self.iter().any(|t| t.visit_with(visitor))
+ }
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::collections::range::RangeArgument;
use std::fmt::Debug;
use std::iter::{self, FromIterator};
use std::slice;
self.raw.iter_mut().enumerate().map(IntoIdx { _marker: PhantomData })
}
+ #[inline]
+ pub fn drain<'a, R: RangeArgument<usize>>(
+ &'a mut self, range: R) -> impl Iterator<Item=T> + 'a {
+ self.raw.drain(range)
+ }
+
+ #[inline]
+ pub fn drain_enumerated<'a, R: RangeArgument<usize>>(
+ &'a mut self, range: R) -> impl Iterator<Item=(I, T)> + 'a {
+ self.raw.drain(range).enumerate().map(IntoIdx { _marker: PhantomData })
+ }
+
#[inline]
pub fn last(&self) -> Option<I> {
self.len().checked_sub(1).map(I::new)
pub fn truncate(&mut self, a: usize) {
self.raw.truncate(a)
}
+
+ #[inline]
+ pub fn get(&self, index: I) -> Option<&T> {
+ self.raw.get(index.index())
+ }
+
+ #[inline]
+ pub fn get_mut(&mut self, index: I) -> Option<&mut T> {
+ self.raw.get_mut(index.index())
+ }
}
impl<I: Idx, T> Index<I> for IndexVec<I, T> {
#![feature(associated_consts)]
#![feature(unsize)]
#![feature(i128_type)]
+#![feature(conservative_impl_trait)]
#![cfg_attr(unix, feature(libc))]
#![cfg_attr(test, feature(test))]