Skip to content

Commit 280f69d

Browse files
Fix IndexVec::drain_enumerated
1 parent 6ba6d22 commit 280f69d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

compiler/rustc_index/src/vec.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,12 @@ impl<I: Idx, T> IndexVec<I, T> {
207207
&'a mut self,
208208
range: R,
209209
) -> impl Iterator<Item = (I, T)> + 'a {
210-
self.raw.drain(range).enumerate().map(|(n, t)| (I::new(n), t))
210+
let begin = match range.start_bound() {
211+
std::ops::Bound::Included(i) => *i,
212+
std::ops::Bound::Excluded(i) => i.checked_add(1).unwrap(),
213+
std::ops::Bound::Unbounded => 0,
214+
};
215+
self.raw.drain(range).enumerate().map(move |(n, t)| (I::new(begin + n), t))
211216
}
212217

213218
#[inline]

compiler/rustc_trait_selection/src/solve/trait_goals/structural_traits.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ pub(super) fn instantiate_constituent_tys_for_auto_trait<'tcx>(
3030
| ty::Foreign(..)
3131
| ty::Alias(ty::Projection, ..)
3232
| ty::Bound(..)
33-
| ty::Infer(ty::TyVar(_)) => {
34-
// FIXME: Do we need to mark anything as ambiguous here? Yeah?
35-
Err(NoSolution)
36-
}
33+
| ty::Infer(ty::TyVar(_)) => Err(NoSolution),
3734

3835
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => bug!(),
3936

@@ -101,9 +98,8 @@ pub(super) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
10198
| ty::Dynamic(..)
10299
| ty::Foreign(..)
103100
| ty::Alias(..)
104-
| ty::Param(_) => Err(NoSolution),
105-
106-
ty::Infer(ty::TyVar(_)) => bug!("FIXME: ambiguous"),
101+
| ty::Param(_)
102+
| ty::Infer(ty::TyVar(_)) => Err(NoSolution),
107103

108104
ty::Placeholder(..)
109105
| ty::Bound(..)
@@ -151,9 +147,8 @@ pub(super) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
151147
| ty::Ref(_, _, Mutability::Mut)
152148
| ty::Adt(_, _)
153149
| ty::Alias(_, _)
154-
| ty::Param(_) => Err(NoSolution),
155-
156-
ty::Infer(ty::TyVar(_)) => bug!("FIXME: ambiguous"),
150+
| ty::Param(_)
151+
| ty::Infer(ty::TyVar(_)) => Err(NoSolution),
157152

158153
ty::Placeholder(..)
159154
| ty::Bound(..)

0 commit comments

Comments
 (0)