diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2021-06-08 16:48:58 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2021-06-08 17:17:45 -0300 |
| commit | 0ad09f938606b1a603300a93570da4a16cb7b5f2 (patch) | |
| tree | 3259d195181fb9f905c08221a6658829c2f6d733 | |
| parent | ecd78e985e7049d011e4de5e4fe04f5c9fe5af31 (diff) | |
| download | rust-0ad09f938606b1a603300a93570da4a16cb7b5f2.tar.gz rust-0ad09f938606b1a603300a93570da4a16cb7b5f2.zip | |
Do not deconstruct OpaqueTypeKey to make the code more clear
| -rw-r--r-- | compiler/rustc_typeck/src/check/writeback.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/rustc_typeck/src/check/writeback.rs b/compiler/rustc_typeck/src/check/writeback.rs index 3984537a056..032cc7ee233 100644 --- a/compiler/rustc_typeck/src/check/writeback.rs +++ b/compiler/rustc_typeck/src/check/writeback.rs @@ -15,7 +15,7 @@ use rustc_middle::hir::place::Place as HirPlace; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCast}; use rustc_middle::ty::fold::{TypeFoldable, TypeFolder}; -use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt}; +use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::symbol::sym; use rustc_span::Span; use rustc_trait_selection::opaque_types::InferCtxtExt; @@ -475,10 +475,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { } fn visit_opaque_types(&mut self, span: Span) { - for &(opaque_type_key @ OpaqueTypeKey { def_id, substs }, 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()); + for &(opaque_type_key, opaque_defn) in self.fcx.opaque_types.borrow().iter() { + let hir_id = + self.tcx().hir().local_def_id_to_hir_id(opaque_type_key.def_id.expect_local()); let instantiated_ty = self.resolve(opaque_defn.concrete_ty, &hir_id); debug_assert!(!instantiated_ty.has_escaping_bound_vars()); @@ -506,17 +505,17 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { if let ty::Opaque(definition_ty_def_id, _substs) = *definition_ty.kind() { if let hir::OpaqueTyOrigin::Misc | hir::OpaqueTyOrigin::TyAlias = opaque_defn.origin { - if def_id == definition_ty_def_id { + if opaque_type_key.def_id == definition_ty_def_id { debug!( "skipping adding concrete definition for opaque type {:?} {:?}", - opaque_defn, def_id + opaque_defn, opaque_type_key.def_id ); skip_add = true; } } } - if !substs.needs_infer() { + if !opaque_type_key.substs.needs_infer() { // We only want to add an entry into `concrete_opaque_types` // if we actually found a defining usage of this opaque type. // Otherwise, we do nothing - we'll either find a defining usage @@ -533,7 +532,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { span, "`visit_opaque_types` tried to write different types for the same \ opaque type: {:?}, {:?}, {:?}, {:?}", - def_id, + opaque_type_key.def_id, definition_ty, opaque_defn, old_concrete_ty, |
