Skip to content

Commit

Permalink
Construct AssociatedItems from an iterator instead of a Vec
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed Feb 19, 2020
1 parent 186cbfa commit a0212ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub struct AssociatedItems {

impl AssociatedItems {
/// Constructs an `AssociatedItems` map from a series of `ty::AssocItem`s in definition order.
pub fn new(items_in_def_order: Vec<ty::AssocItem>) -> Self {
pub fn new(items_in_def_order: impl IntoIterator<Item = ty::AssocItem>) -> Self {
let items = items_in_def_order.into_iter().map(|item| (item.ident.name, item)).collect();
AssociatedItems { items }
}
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_ty/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
}

fn associated_items<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ty::AssociatedItems {
let items =
tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did)).collect();
let items = tcx.associated_item_def_ids(def_id).iter().map(|did| tcx.associated_item(*did));
tcx.arena.alloc(ty::AssociatedItems::new(items))
}

Expand Down

0 comments on commit a0212ba

Please sign in to comment.