Skip to content

Commit 27231ba

Browse files
Rollup merge of #156048 - JonathanBrouwer:diverging_ty_vids, r=WaffleLapkin
Make `diverging_type_vars` a vec of `TyVid` r? @lcnr The following changes, in separate commits: * Make its elements a `TyVid`, since there should never by any other types than `TyVars` in there * Make it a vec, since it being a set doesn't make much sense. You never really should do a `contains` on it, since you should normalize the tyvids in the set to their root var first.
2 parents e0c8355 + c17d24e commit 27231ba

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

compiler/rustc_hir_typeck/src/fallback.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
211211
let diverging_roots: UnordSet<ty::TyVid> = self
212212
.diverging_type_vars
213213
.borrow()
214-
.items()
215-
.map(|&ty| self.shallow_resolve(ty))
214+
.iter()
215+
.map(|&ty_id| self.shallow_resolve(Ty::new_var(self.tcx, ty_id)))
216216
.filter_map(|ty| ty.ty_vid())
217217
.map(|vid| self.root_var(vid))
218218
.collect();

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
321321
for a in &adj {
322322
match a.kind {
323323
Adjust::NeverToAny => {
324-
if a.target.is_ty_var() {
325-
self.diverging_type_vars.borrow_mut().insert(a.target);
324+
if let ty::Infer(ty::TyVar(a_id)) = a.target.kind() {
325+
self.diverging_type_vars.borrow_mut().push(*a_id);
326326
debug!("apply_adjustments: adding `{:?}` as diverging type var", a.target);
327327
}
328328
}

compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use std::cell::{Cell, RefCell};
22
use std::ops::Deref;
33

4-
use rustc_data_structures::unord::UnordSet;
54
use rustc_hir::def_id::LocalDefId;
65
use rustc_hir::{self as hir, HirId, HirIdMap};
76
use rustc_infer::infer::{InferCtxt, InferOk, OpaqueTypeStorageEntries, TyCtxtInferExt};
87
use rustc_middle::span_bug;
9-
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, TypingMode};
8+
use rustc_middle::ty::{self, Ty, TyCtxt, TyVid, TypeVisitableExt, TypingMode};
109
use rustc_span::Span;
1110
use rustc_span::def_id::LocalDefIdMap;
1211
use rustc_trait_selection::traits::{self, FulfillmentError, TraitEngine, TraitEngineExt as _};
@@ -66,7 +65,7 @@ pub(crate) struct TypeckRootCtxt<'tcx> {
6665
/// Whenever we introduce an adjustment from `!` into a type variable,
6766
/// we record that type variable here. This is later used to inform
6867
/// fallback. See the `fallback` module for details.
69-
pub(super) diverging_type_vars: RefCell<UnordSet<Ty<'tcx>>>,
68+
pub(super) diverging_type_vars: RefCell<Vec<TyVid>>,
7069
}
7170

7271
impl<'tcx> Deref for TypeckRootCtxt<'tcx> {

0 commit comments

Comments
 (0)