From f1150ba69c558c00b7d827ab408e18af8298306e Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 5 Jan 2021 17:04:48 +0100 Subject: [PATCH] Revert "Rollup merge of #80637 - LingMan:filter, r=oli-obk" This reverts commit faf8beddef859bbb387a24c536505d833c3821a5, reversing changes made to 1c6593c473f2cd67a1199dac89fb0e6a811d26ab. --- .../infer/error_reporting/need_type_info.rs | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs index e097264ec8aa0..373f0a602c0ef 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs @@ -43,18 +43,22 @@ impl<'a, 'tcx> FindHirNodeVisitor<'a, 'tcx> { } fn node_ty_contains_target(&mut self, hir_id: HirId) -> Option> { - self.infcx + let ty_opt = self + .infcx .in_progress_typeck_results - .and_then(|typeck_results| typeck_results.borrow().node_type_opt(hir_id)) - .map(|ty| self.infcx.resolve_vars_if_possible(ty)) - .filter(|ty| { - ty.walk().any(|inner| { + .and_then(|typeck_results| typeck_results.borrow().node_type_opt(hir_id)); + match ty_opt { + Some(ty) => { + let ty = self.infcx.resolve_vars_if_possible(ty); + if ty.walk().any(|inner| { inner == self.target || match (inner.unpack(), self.target.unpack()) { (GenericArgKind::Type(inner_ty), GenericArgKind::Type(target_ty)) => { - use ty::{Infer, TyVar}; match (inner_ty.kind(), target_ty.kind()) { - (&Infer(TyVar(a_vid)), &Infer(TyVar(b_vid))) => self + ( + &ty::Infer(ty::TyVar(a_vid)), + &ty::Infer(ty::TyVar(b_vid)), + ) => self .infcx .inner .borrow_mut() @@ -65,8 +69,14 @@ impl<'a, 'tcx> FindHirNodeVisitor<'a, 'tcx> { } _ => false, } - }) - }) + }) { + Some(ty) + } else { + None + } + } + None => None, + } } }