diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 039e9953814..f18067145dd 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -46,17 +46,20 @@ pub struct ModuleItems { } impl ModuleItems { - pub fn items(&self) -> impl Iterator { - self.items.to_vec().into_iter() + pub fn items(&self) -> impl Iterator + '_ { + self.items.iter().copied() } - pub fn trait_items(&self) -> impl Iterator { - self.trait_items.to_vec().into_iter() + + pub fn trait_items(&self) -> impl Iterator + '_ { + self.trait_items.iter().copied() } - pub fn impl_items(&self) -> impl Iterator { - self.impl_items.to_vec().into_iter() + + pub fn impl_items(&self) -> impl Iterator + '_ { + self.impl_items.iter().copied() } - pub fn foreign_items(&self) -> impl Iterator { - self.foreign_items.to_vec().into_iter() + + pub fn foreign_items(&self) -> impl Iterator + '_ { + self.foreign_items.iter().copied() } }