Skip to content

Commit 0ad09f9

Browse files
committed
Do not deconstruct OpaqueTypeKey to make the code more clear
1 parent ecd78e9 commit 0ad09f9

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

compiler/rustc_typeck/src/check/writeback.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::hir::place::Place as HirPlace;
1515
use rustc_middle::mir::FakeReadCause;
1616
use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCast};
1717
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder};
18-
use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt};
18+
use rustc_middle::ty::{self, Ty, TyCtxt};
1919
use rustc_span::symbol::sym;
2020
use rustc_span::Span;
2121
use rustc_trait_selection::opaque_types::InferCtxtExt;
@@ -475,10 +475,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
475475
}
476476

477477
fn visit_opaque_types(&mut self, span: Span) {
478-
for &(opaque_type_key @ OpaqueTypeKey { def_id, substs }, opaque_defn) in
479-
self.fcx.opaque_types.borrow().iter()
480-
{
481-
let hir_id = self.tcx().hir().local_def_id_to_hir_id(def_id.expect_local());
478+
for &(opaque_type_key, opaque_defn) in self.fcx.opaque_types.borrow().iter() {
479+
let hir_id =
480+
self.tcx().hir().local_def_id_to_hir_id(opaque_type_key.def_id.expect_local());
482481
let instantiated_ty = self.resolve(opaque_defn.concrete_ty, &hir_id);
483482

484483
debug_assert!(!instantiated_ty.has_escaping_bound_vars());
@@ -506,17 +505,17 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
506505
if let ty::Opaque(definition_ty_def_id, _substs) = *definition_ty.kind() {
507506
if let hir::OpaqueTyOrigin::Misc | hir::OpaqueTyOrigin::TyAlias = opaque_defn.origin
508507
{
509-
if def_id == definition_ty_def_id {
508+
if opaque_type_key.def_id == definition_ty_def_id {
510509
debug!(
511510
"skipping adding concrete definition for opaque type {:?} {:?}",
512-
opaque_defn, def_id
511+
opaque_defn, opaque_type_key.def_id
513512
);
514513
skip_add = true;
515514
}
516515
}
517516
}
518517

519-
if !substs.needs_infer() {
518+
if !opaque_type_key.substs.needs_infer() {
520519
// We only want to add an entry into `concrete_opaque_types`
521520
// if we actually found a defining usage of this opaque type.
522521
// Otherwise, we do nothing - we'll either find a defining usage
@@ -533,7 +532,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
533532
span,
534533
"`visit_opaque_types` tried to write different types for the same \
535534
opaque type: {:?}, {:?}, {:?}, {:?}",
536-
def_id,
535+
opaque_type_key.def_id,
537536
definition_ty,
538537
opaque_defn,
539538
old_concrete_ty,

0 commit comments

Comments
 (0)