From fee9e9b9d36649fe7ebc00b1eeefc6d97052798f Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 17 Aug 2022 22:00:53 +0000 Subject: [PATCH] Do not leak variables from probe --- compiler/rustc_typeck/src/check/inherited.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_typeck/src/check/inherited.rs b/compiler/rustc_typeck/src/check/inherited.rs index 1a000f77b0f..371fc26154c 100644 --- a/compiler/rustc_typeck/src/check/inherited.rs +++ b/compiler/rustc_typeck/src/check/inherited.rs @@ -105,10 +105,13 @@ pub fn build(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> InheritedBuilder<'tcx> { let mut fulfillment_ctxt = FulfillmentContext::new_in_snapshot(); fulfillment_ctxt.register_predicate_obligations(infcx, obligations); if fulfillment_ctxt.select_all_or_error(infcx).is_empty() { - infcx.resolve_vars_if_possible(normalized_fn_sig) - } else { - fn_sig + let normalized_fn_sig = + infcx.resolve_vars_if_possible(normalized_fn_sig); + if !normalized_fn_sig.needs_infer() { + return normalized_fn_sig; + } } + fn_sig }) })), def_id,