Fix IndexVec::drain_enumerated

This commit is contained in:
Michael Goulet 2023-01-19 15:24:00 +00:00
parent 6ba6d22bdf
commit 280f69d858
2 changed files with 11 additions and 11 deletions

View file

@ -207,7 +207,12 @@ impl<I: Idx, T> IndexVec<I, T> {
&'a mut self, &'a mut self,
range: R, range: R,
) -> impl Iterator<Item = (I, T)> + 'a { ) -> impl Iterator<Item = (I, T)> + 'a {
self.raw.drain(range).enumerate().map(|(n, t)| (I::new(n), t)) let begin = match range.start_bound() {
std::ops::Bound::Included(i) => *i,
std::ops::Bound::Excluded(i) => i.checked_add(1).unwrap(),
std::ops::Bound::Unbounded => 0,
};
self.raw.drain(range).enumerate().map(move |(n, t)| (I::new(begin + n), t))
} }
#[inline] #[inline]

View file

@ -30,10 +30,7 @@ pub(super) fn instantiate_constituent_tys_for_auto_trait<'tcx>(
| ty::Foreign(..) | ty::Foreign(..)
| ty::Alias(ty::Projection, ..) | ty::Alias(ty::Projection, ..)
| ty::Bound(..) | ty::Bound(..)
| ty::Infer(ty::TyVar(_)) => { | ty::Infer(ty::TyVar(_)) => Err(NoSolution),
// FIXME: Do we need to mark anything as ambiguous here? Yeah?
Err(NoSolution)
}
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => bug!(), ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => bug!(),
@ -101,9 +98,8 @@ pub(super) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
| ty::Dynamic(..) | ty::Dynamic(..)
| ty::Foreign(..) | ty::Foreign(..)
| ty::Alias(..) | ty::Alias(..)
| ty::Param(_) => Err(NoSolution), | ty::Param(_)
| ty::Infer(ty::TyVar(_)) => Err(NoSolution),
ty::Infer(ty::TyVar(_)) => bug!("FIXME: ambiguous"),
ty::Placeholder(..) ty::Placeholder(..)
| ty::Bound(..) | ty::Bound(..)
@ -151,9 +147,8 @@ pub(super) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
| ty::Ref(_, _, Mutability::Mut) | ty::Ref(_, _, Mutability::Mut)
| ty::Adt(_, _) | ty::Adt(_, _)
| ty::Alias(_, _) | ty::Alias(_, _)
| ty::Param(_) => Err(NoSolution), | ty::Param(_)
| ty::Infer(ty::TyVar(_)) => Err(NoSolution),
ty::Infer(ty::TyVar(_)) => bug!("FIXME: ambiguous"),
ty::Placeholder(..) ty::Placeholder(..)
| ty::Bound(..) | ty::Bound(..)