Skip to content

Commit 2bc723f

Browse files
committed
Change opaque type map to be a VecMap
1 parent aa7024b commit 2bc723f

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

compiler/rustc_mir/src/borrow_check/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12811281
.eq(output_ty, revealed_ty)?,
12821282
);
12831283

1284-
for (&opaque_def_id, opaque_decl) in &opaque_type_map {
1284+
for &(opaque_def_id, opaque_decl) in &opaque_type_map {
12851285
let resolved_ty = infcx.resolve_vars_if_possible(opaque_decl.concrete_ty);
12861286
let concrete_is_opaque = if let ty::Opaque(def_id, _) = resolved_ty.kind() {
12871287
*def_id == opaque_def_id

compiler/rustc_trait_selection/src/opaque_types.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ use crate::infer::InferCtxtExt as _;
22
use crate::traits::{self, PredicateObligation};
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_data_structures::sync::Lrc;
5+
use rustc_data_structures::vec_map::VecMap;
56
use rustc_hir as hir;
6-
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
7+
use rustc_hir::def_id::{DefId, LocalDefId};
78
use rustc_hir::Node;
89
use rustc_infer::infer::error_reporting::unexpected_hidden_region_diagnostic;
910
use rustc_infer::infer::free_regions::FreeRegionRelations;
@@ -16,7 +17,7 @@ use rustc_span::Span;
1617

1718
use std::ops::ControlFlow;
1819

19-
pub type OpaqueTypeMap<'tcx> = DefIdMap<OpaqueTypeDecl<'tcx>>;
20+
pub type OpaqueTypeMap<'tcx> = VecMap<DefId, OpaqueTypeDecl<'tcx>>;
2021

2122
/// Information about the opaque types whose values we
2223
/// are inferring in this function (these are the `impl Trait` that
@@ -370,10 +371,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
370371
) {
371372
debug!("constrain_opaque_types()");
372373

373-
for (&def_id, opaque_defn) in opaque_types {
374+
for &(def_id, opaque_defn) in opaque_types {
374375
self.constrain_opaque_type(
375376
def_id,
376-
opaque_defn,
377+
&opaque_defn,
377378
GenerateMemberConstraints::WhenRequired,
378379
free_region_relations,
379380
);

compiler/rustc_typeck/src/check/inherited.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ use super::callee::DeferredCallResolution;
22
use super::MaybeInProgressTables;
33

44
use rustc_data_structures::fx::FxHashMap;
5+
use rustc_data_structures::vec_map::VecMap;
56
use rustc_hir as hir;
6-
use rustc_hir::def_id::{DefIdMap, LocalDefId};
7+
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
78
use rustc_hir::HirIdMap;
89
use rustc_infer::infer;
910
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
@@ -58,7 +59,7 @@ pub struct Inherited<'a, 'tcx> {
5859
// associated fresh inference variable. Writeback resolves these
5960
// variables to get the concrete type, which can be used to
6061
// 'de-opaque' OpaqueTypeDecl, after typeck is done with all functions.
61-
pub(super) opaque_types: RefCell<DefIdMap<OpaqueTypeDecl<'tcx>>>,
62+
pub(super) opaque_types: RefCell<VecMap<DefId, OpaqueTypeDecl<'tcx>>>,
6263

6364
/// A map from inference variables created from opaque
6465
/// type instantiations (`ty::Infer`) to the actual opaque

compiler/rustc_typeck/src/check/writeback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
475475
}
476476

477477
fn visit_opaque_types(&mut self, span: Span) {
478-
for (&def_id, opaque_defn) in self.fcx.opaque_types.borrow().iter() {
478+
for &(def_id, opaque_defn) in self.fcx.opaque_types.borrow().iter() {
479479
let hir_id = self.tcx().hir().local_def_id_to_hir_id(def_id.expect_local());
480480
let instantiated_ty = self.resolve(opaque_defn.concrete_ty, &hir_id);
481481

0 commit comments

Comments
 (0)