Skip to content

Commit

Permalink
Change opaque type map to be a VecMap
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Jun 7, 2021
1 parent aa7024b commit 2bc723f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/borrow_check/type_check/mod.rs
Expand Up @@ -1281,7 +1281,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
.eq(output_ty, revealed_ty)?,
);

for (&opaque_def_id, opaque_decl) in &opaque_type_map {
for &(opaque_def_id, opaque_decl) in &opaque_type_map {
let resolved_ty = infcx.resolve_vars_if_possible(opaque_decl.concrete_ty);
let concrete_is_opaque = if let ty::Opaque(def_id, _) = resolved_ty.kind() {
*def_id == opaque_def_id
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_trait_selection/src/opaque_types.rs
Expand Up @@ -2,8 +2,9 @@ use crate::infer::InferCtxtExt as _;
use crate::traits::{self, PredicateObligation};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::vec_map::VecMap;
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::Node;
use rustc_infer::infer::error_reporting::unexpected_hidden_region_diagnostic;
use rustc_infer::infer::free_regions::FreeRegionRelations;
Expand All @@ -16,7 +17,7 @@ use rustc_span::Span;

use std::ops::ControlFlow;

pub type OpaqueTypeMap<'tcx> = DefIdMap<OpaqueTypeDecl<'tcx>>;
pub type OpaqueTypeMap<'tcx> = VecMap<DefId, OpaqueTypeDecl<'tcx>>;

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

for (&def_id, opaque_defn) in opaque_types {
for &(def_id, opaque_defn) in opaque_types {
self.constrain_opaque_type(
def_id,
opaque_defn,
&opaque_defn,
GenerateMemberConstraints::WhenRequired,
free_region_relations,
);
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_typeck/src/check/inherited.rs
Expand Up @@ -2,8 +2,9 @@ use super::callee::DeferredCallResolution;
use super::MaybeInProgressTables;

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

/// A map from inference variables created from opaque
/// type instantiations (`ty::Infer`) to the actual opaque
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/writeback.rs
Expand Up @@ -475,7 +475,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
}

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

Expand Down

0 comments on commit 2bc723f

Please sign in to comment.