diff --git a/compiler/rustc_hir_typeck/src/fallback.rs b/compiler/rustc_hir_typeck/src/fallback.rs index 3ce363e1e9c7e..4dfbbc6c6350c 100644 --- a/compiler/rustc_hir_typeck/src/fallback.rs +++ b/compiler/rustc_hir_typeck/src/fallback.rs @@ -211,8 +211,8 @@ impl<'tcx> FnCtxt<'_, 'tcx> { let diverging_roots: UnordSet = self .diverging_type_vars .borrow() - .items() - .map(|&ty| self.shallow_resolve(ty)) + .iter() + .map(|&ty_id| self.shallow_resolve(Ty::new_var(self.tcx, ty_id))) .filter_map(|ty| ty.ty_vid()) .map(|vid| self.root_var(vid)) .collect(); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 9a54d651fe73a..360236f048dec 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -321,8 +321,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for a in &adj { match a.kind { Adjust::NeverToAny => { - if a.target.is_ty_var() { - self.diverging_type_vars.borrow_mut().insert(a.target); + if let ty::Infer(ty::TyVar(a_id)) = a.target.kind() { + self.diverging_type_vars.borrow_mut().push(*a_id); debug!("apply_adjustments: adding `{:?}` as diverging type var", a.target); } } diff --git a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs index ff2fc66e1d477..e4dcead1f7954 100644 --- a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs +++ b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs @@ -1,12 +1,11 @@ use std::cell::{Cell, RefCell}; use std::ops::Deref; -use rustc_data_structures::unord::UnordSet; use rustc_hir::def_id::LocalDefId; use rustc_hir::{self as hir, HirId, HirIdMap}; use rustc_infer::infer::{InferCtxt, InferOk, OpaqueTypeStorageEntries, TyCtxtInferExt}; use rustc_middle::span_bug; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, TypingMode}; +use rustc_middle::ty::{self, Ty, TyCtxt, TyVid, TypeVisitableExt, TypingMode}; use rustc_span::Span; use rustc_span::def_id::LocalDefIdMap; use rustc_trait_selection::traits::{self, FulfillmentError, TraitEngine, TraitEngineExt as _}; @@ -66,7 +65,7 @@ pub(crate) struct TypeckRootCtxt<'tcx> { /// Whenever we introduce an adjustment from `!` into a type variable, /// we record that type variable here. This is later used to inform /// fallback. See the `fallback` module for details. - pub(super) diverging_type_vars: RefCell>>, + pub(super) diverging_type_vars: RefCell>, } impl<'tcx> Deref for TypeckRootCtxt<'tcx> {