]> git.lizzy.rs Git - rust.git/commitdiff
Make concrete_opaque_types be FxHashSet<DefId>
authorSantiago Pastorino <spastorino@gmail.com>
Mon, 9 Aug 2021 23:34:09 +0000 (20:34 -0300)
committerSantiago Pastorino <spastorino@gmail.com>
Wed, 11 Aug 2021 12:48:25 +0000 (09:48 -0300)
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_typeck/src/check/writeback.rs
compiler/rustc_typeck/src/collect/type_of.rs

index 3bdd91d2136093af3fa003d7323a96d7e1c996c0..ef0392e51970b27f96a16cdc942036e880811930 100644 (file)
@@ -32,7 +32,6 @@
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc_data_structures::steal::Steal;
 use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
-use rustc_data_structures::vec_map::VecMap;
 use rustc_errors::ErrorReported;
 use rustc_hir as hir;
 use rustc_hir::def::{DefKind, Res};
@@ -46,7 +45,6 @@
 use rustc_index::vec::{Idx, IndexVec};
 use rustc_macros::HashStable;
 use rustc_middle::mir::FakeReadCause;
-use rustc_middle::ty::OpaqueTypeKey;
 use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
 use rustc_session::config::{BorrowckMode, CrateType, OutputFilenames};
 use rustc_session::lint::{Level, Lint};
@@ -477,7 +475,7 @@ pub struct TypeckResults<'tcx> {
 
     /// All the opaque types that are restricted to concrete types
     /// by this function.
-    pub concrete_opaque_types: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
+    pub concrete_opaque_types: FxHashSet<DefId>,
 
     /// Tracks the minimum captures required for a closure;
     /// see `MinCaptureInformationMap` for more details.
index 959ab69a679eb1d6075b02f1f42a2daf021679e1..a13157b460828a809cf7a251dbde2164bf729a8a 100644 (file)
@@ -552,23 +552,7 @@ fn visit_opaque_types(&mut self, span: Span) {
             // in some other location, or we'll end up emitting an error due
             // to the lack of defining usage
             if !skip_add {
-                let old_concrete_ty = self
-                    .typeck_results
-                    .concrete_opaque_types
-                    .insert(opaque_type_key, definition_ty);
-                if let Some(old_concrete_ty) = old_concrete_ty {
-                    if old_concrete_ty != definition_ty {
-                        span_bug!(
-                            span,
-                            "`visit_opaque_types` tried to write different types for the same \
-                                 opaque type: {:?}, {:?}, {:?}, {:?}",
-                            opaque_type_key.def_id,
-                            definition_ty,
-                            opaque_defn,
-                            old_concrete_ty,
-                        );
-                    }
-                }
+                self.typeck_results.concrete_opaque_types.insert(opaque_type_key.def_id);
             }
         }
     }
index b9483d6f987602c665b5867facaccbd1b12851e8..e63c3346e02b1dfc5a4a2f3ae53e8f45cb6f9286 100644 (file)
@@ -540,13 +540,7 @@ fn check(&mut self, def_id: LocalDefId) {
             }
             // Calling `mir_borrowck` can lead to cycle errors through
             // const-checking, avoid calling it if we don't have to.
-            if self
-                .tcx
-                .typeck(def_id)
-                .concrete_opaque_types
-                .any_value_matching(|(key, _)| key.def_id == self.def_id)
-                .is_none()
-            {
+            if !self.tcx.typeck(def_id).concrete_opaque_types.contains(&self.def_id) {
                 debug!("no constraints in typeck results");
                 return;
             }