diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-02-19 12:55:59 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-02-19 12:55:59 -0800 |
| commit | a0212ba40fdeb07626449b5790537aca542b51d2 (patch) | |
| tree | 8700b0d63176ade44dd26ce9a902233b87f2f3bc | |
| parent | 186cbfad8982cf0f40a311d0e76563662095ed36 (diff) | |
| download | rust-a0212ba40fdeb07626449b5790537aca542b51d2.tar.gz rust-a0212ba40fdeb07626449b5790537aca542b51d2.zip | |
Construct `AssociatedItems` from an iterator instead of a `Vec`
| -rw-r--r-- | src/librustc/ty/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc_ty/ty.rs | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index fa46f521ba5..77ac319547b 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -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 } } diff --git a/src/librustc_ty/ty.rs b/src/librustc_ty/ty.rs index 916a819090c..d466bbcca79 100644 --- a/src/librustc_ty/ty.rs +++ b/src/librustc_ty/ty.rs @@ -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)) } |
