From 9bb40b09b78f650b75d22a869a8b1bf18937aba3 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 23 Jul 2018 14:48:37 +0100 Subject: [PATCH] Make prohibit_generics take IntoIterators --- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/mod.rs | 20 +++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 18bd00d43d6..772ec39d8f0 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -988,7 +988,7 @@ fn qpath_to_ty(&self, self.normalize_ty(span, tcx.mk_projection(item_def_id, trait_ref.substs)) } - pub fn prohibit_generics(&self, segments: &[hir::PathSegment]) { + pub fn prohibit_generics<'a, T: IntoIterator>(&self, segments: T) { for segment in segments { segment.with_generic_args(|generic_args| { let (mut err_for_lt, mut err_for_ty) = (false, false); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 66f5e57ef6d..c1bf6b0fe31 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4913,19 +4913,13 @@ pub fn instantiate_value_path(&self, for PathSeg(_, index) in &path_segs { generic_segs.insert(index); } - let segs: Vec<_> = segments - .iter() - .enumerate() - .filter_map(|(index, seg)| { - if !generic_segs.contains(&index) { - Some(seg) - } else { - None - } - }) - .cloned() - .collect(); - AstConv::prohibit_generics(self, &segs); + AstConv::prohibit_generics(self, segments.iter().enumerate().filter_map(|(index, seg)| { + if !generic_segs.contains(&index) { + Some(seg) + } else { + None + } + })); match def { Def::Local(nid) | Def::Upvar(nid, ..) => {