From 2adc8b529ada1d697ec51a94164d9b3f66a40b79 Mon Sep 17 00:00:00 2001 From: Flavio Percoco Date: Thu, 15 Jan 2015 10:09:00 +0100 Subject: [PATCH] populate impls *before* clonning the impls vec --- src/librustc_typeck/coherence/overlap.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 159b9d853c497..ce7ba9ac11e65 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -39,7 +39,12 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> { // check can populate this table further with impls from other // crates. let trait_def_ids: Vec<(ast::DefId, Vec)> = - self.tcx.trait_impls.borrow().iter().map(|(&k, v)| (k, v.borrow().clone())).collect(); + self.tcx.trait_impls.borrow().iter().map(|(&k, v)| { + // FIXME -- it seems like this method actually pushes + // duplicate impls onto the list + ty::populate_implementations_for_trait_if_necessary(self.tcx, k); + (k, v.borrow().clone()) + }).collect(); for &(trait_def_id, ref impls) in trait_def_ids.iter() { self.check_for_overlapping_impls_of_trait(trait_def_id, impls); @@ -53,11 +58,6 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> { debug!("check_for_overlapping_impls_of_trait(trait_def_id={})", trait_def_id.repr(self.tcx)); - // FIXME -- it seems like this method actually pushes - // duplicate impls onto the list - ty::populate_implementations_for_trait_if_necessary(self.tcx, - trait_def_id); - for (i, &impl1_def_id) in trait_impls.iter().enumerate() { if impl1_def_id.krate != ast::LOCAL_CRATE { // we don't need to check impls if both are external;