Skip to content

Commit a0212ba

Browse files
Construct AssociatedItems from an iterator instead of a Vec
1 parent 186cbfa commit a0212ba

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ pub struct AssociatedItems {
277277

278278
impl AssociatedItems {
279279
/// Constructs an `AssociatedItems` map from a series of `ty::AssocItem`s in definition order.
280-
pub fn new(items_in_def_order: Vec<ty::AssocItem>) -> Self {
280+
pub fn new(items_in_def_order: impl IntoIterator<Item = ty::AssocItem>) -> Self {
281281
let items = items_in_def_order.into_iter().map(|item| (item.ident.name, item)).collect();
282282
AssociatedItems { items }
283283
}

src/librustc_ty/ty.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
211211
}
212212

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

0 commit comments

Comments
 (0)