Skip to content

Commit fe9a02c

Browse files
Rollup merge of #79460 - bugadani:simplify, r=jonas-schievink
Remove intermediate vectors from `add_bounds` This PR removes two short lived vectors that don't serve any obvious purpose.
2 parents 1337586 + d212ea7 commit fe9a02c

File tree

1 file changed

+5
-14
lines changed
  • compiler/rustc_typeck/src/astconv

1 file changed

+5
-14
lines changed

compiler/rustc_typeck/src/astconv/mod.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -823,34 +823,25 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
823823
ast_bounds: &[hir::GenericBound<'_>],
824824
bounds: &mut Bounds<'tcx>,
825825
) {
826-
let mut trait_bounds = Vec::new();
827-
let mut region_bounds = Vec::new();
828-
829826
let constness = self.default_constness_for_trait_bounds();
830827
for ast_bound in ast_bounds {
831828
match *ast_bound {
832829
hir::GenericBound::Trait(ref b, hir::TraitBoundModifier::None) => {
833-
trait_bounds.push((b, constness))
830+
self.instantiate_poly_trait_ref(b, constness, param_ty, bounds);
834831
}
835832
hir::GenericBound::Trait(ref b, hir::TraitBoundModifier::MaybeConst) => {
836-
trait_bounds.push((b, Constness::NotConst))
833+
self.instantiate_poly_trait_ref(b, Constness::NotConst, param_ty, bounds);
837834
}
838835
hir::GenericBound::Trait(_, hir::TraitBoundModifier::Maybe) => {}
839836
hir::GenericBound::LangItemTrait(lang_item, span, hir_id, args) => self
840837
.instantiate_lang_item_trait_ref(
841838
lang_item, span, hir_id, args, param_ty, bounds,
842839
),
843-
hir::GenericBound::Outlives(ref l) => region_bounds.push(l),
840+
hir::GenericBound::Outlives(ref l) => {
841+
bounds.region_bounds.push((self.ast_region_to_region(l, None), l.span))
842+
}
844843
}
845844
}
846-
847-
for (bound, constness) in trait_bounds {
848-
let _ = self.instantiate_poly_trait_ref(bound, constness, param_ty, bounds);
849-
}
850-
851-
bounds.region_bounds.extend(
852-
region_bounds.into_iter().map(|r| (self.ast_region_to_region(r, None), r.span)),
853-
);
854845
}
855846

856847
/// Translates a list of bounds from the HIR into the `Bounds` data structure.

0 commit comments

Comments
 (0)