Don't collect into a Vec that is immediately being iterated on again.

This commit is contained in:
Oli Scherer 2021-08-10 11:03:10 +00:00
parent 7af445dc15
commit 93c4aa80b8

View file

@ -344,12 +344,11 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
// check.) // check.)
let bounds = tcx.explicit_item_bounds(def_id); let bounds = tcx.explicit_item_bounds(def_id);
debug!("{:#?}", bounds); debug!("{:#?}", bounds);
let bounds: Vec<_> = let bounds = bounds.iter().map(|(bound, _)| bound.subst(tcx, opaque_type_key.substs));
bounds.iter().map(|(bound, _)| bound.subst(tcx, opaque_type_key.substs)).collect();
debug!("{:#?}", bounds); debug!("{:#?}", bounds);
let opaque_type = tcx.mk_opaque(def_id, opaque_type_key.substs); let opaque_type = tcx.mk_opaque(def_id, opaque_type_key.substs);
let required_region_bounds = required_region_bounds(tcx, opaque_type, bounds.into_iter()); let required_region_bounds = required_region_bounds(tcx, opaque_type, bounds);
if !required_region_bounds.is_empty() { if !required_region_bounds.is_empty() {
for required_region in required_region_bounds { for required_region in required_region_bounds {
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor { concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {