diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs index 7c02de05d26d5..c1d9240ba0634 100644 --- a/src/librustc/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -749,13 +749,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { pub fn plug_leaks(&self, skol_map: SkolemizationMap<'tcx>, snapshot: &CombinedSnapshot, - value: &T) -> T + value: T) -> T where T : TypeFoldable<'tcx> { debug!("plug_leaks(skol_map={:?}, value={:?})", skol_map, value); + if skol_map.is_empty() { + return value; + } + // Compute a mapping from the "taint set" of each skolemized // region back to the `ty::BoundRegion` that it originally // represented. Because `leak_check` passed, we know that @@ -775,7 +779,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // Remove any instantiated type variables from `value`; those can hide // references to regions from the `fold_regions` code below. - let value = self.resolve_type_vars_if_possible(value); + let value = self.resolve_type_vars_if_possible(&value); // Map any skolemization byproducts back to a late-bound // region. Put that late-bound region at whatever the outermost @@ -813,9 +817,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } }); - debug!("plug_leaks: result={:?}", - result); - self.pop_skolemized(skol_map, snapshot); debug!("plug_leaks: result={:?}", result); diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index ea4fc1c25ab42..ddabc53a89a81 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -171,7 +171,7 @@ pub fn poly_project_and_unify_type<'cx, 'gcx, 'tcx>( Ok(result) => { let span = obligation.cause.span; match infcx.leak_check(false, span, &skol_map, snapshot) { - Ok(()) => Ok(infcx.plug_leaks(skol_map, snapshot, &result)), + Ok(()) => Ok(infcx.plug_leaks(skol_map, snapshot, result)), Err(e) => Err(MismatchedProjectionTypes { err: e }), } } diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 9d7131dc96cc5..666311110971d 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -1980,7 +1980,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { normalized_ty, &[]); obligations.push(skol_obligation); - this.infcx().plug_leaks(skol_map, snapshot, &obligations) + this.infcx().plug_leaks(skol_map, snapshot, obligations) }) }).collect() } @@ -2899,7 +2899,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { predicate: predicate.value })) }).collect(); - self.infcx().plug_leaks(skol_map, snapshot, &predicates) + self.infcx().plug_leaks(skol_map, snapshot, predicates) } }