Skip to content

Commit 13d6c5c

Browse files
committed
Auto merge of #87927 - spastorino:use-def-id-typeckresults, r=oli-obk
Make concrete_opaque_types be FxHashSet<DefId> r? `@oli-obk` `@bors` rollup=always
2 parents 61885df + 0aa0d59 commit 13d6c5c

File tree

3 files changed

+3
-27
lines changed

3 files changed

+3
-27
lines changed

compiler/rustc_middle/src/ty/context.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
3232
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3333
use rustc_data_structures::steal::Steal;
3434
use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
35-
use rustc_data_structures::vec_map::VecMap;
3635
use rustc_errors::ErrorReported;
3736
use rustc_hir as hir;
3837
use rustc_hir::def::{DefKind, Res};
@@ -46,7 +45,6 @@ use rustc_hir::{
4645
use rustc_index::vec::{Idx, IndexVec};
4746
use rustc_macros::HashStable;
4847
use rustc_middle::mir::FakeReadCause;
49-
use rustc_middle::ty::OpaqueTypeKey;
5048
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
5149
use rustc_session::config::{BorrowckMode, CrateType, OutputFilenames};
5250
use rustc_session::lint::{Level, Lint};
@@ -477,7 +475,7 @@ pub struct TypeckResults<'tcx> {
477475

478476
/// All the opaque types that are restricted to concrete types
479477
/// by this function.
480-
pub concrete_opaque_types: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
478+
pub concrete_opaque_types: FxHashSet<DefId>,
481479

482480
/// Tracks the minimum captures required for a closure;
483481
/// see `MinCaptureInformationMap` for more details.

compiler/rustc_typeck/src/check/writeback.rs

+1-17
Original file line numberDiff line numberDiff line change
@@ -552,23 +552,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
552552
// in some other location, or we'll end up emitting an error due
553553
// to the lack of defining usage
554554
if !skip_add {
555-
let old_concrete_ty = self
556-
.typeck_results
557-
.concrete_opaque_types
558-
.insert(opaque_type_key, definition_ty);
559-
if let Some(old_concrete_ty) = old_concrete_ty {
560-
if old_concrete_ty != definition_ty {
561-
span_bug!(
562-
span,
563-
"`visit_opaque_types` tried to write different types for the same \
564-
opaque type: {:?}, {:?}, {:?}, {:?}",
565-
opaque_type_key.def_id,
566-
definition_ty,
567-
opaque_defn,
568-
old_concrete_ty,
569-
);
570-
}
571-
}
555+
self.typeck_results.concrete_opaque_types.insert(opaque_type_key.def_id);
572556
}
573557
}
574558
}

compiler/rustc_typeck/src/collect/type_of.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -540,13 +540,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
540540
}
541541
// Calling `mir_borrowck` can lead to cycle errors through
542542
// const-checking, avoid calling it if we don't have to.
543-
if self
544-
.tcx
545-
.typeck(def_id)
546-
.concrete_opaque_types
547-
.any_value_matching(|(key, _)| key.def_id == self.def_id)
548-
.is_none()
549-
{
543+
if !self.tcx.typeck(def_id).concrete_opaque_types.contains(&self.def_id) {
550544
debug!("no constraints in typeck results");
551545
return;
552546
}

0 commit comments

Comments
 (0)