about summary refs log tree commit diff
path: root/compiler/rustc_borrowck
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-07-17 10:37:23 -0700
committerMichael Goulet <michael@errs.io>2022-07-19 16:26:16 +0000
commit5a4601fea56502e4f50df046c4205e678397599b (patch)
tree52a9c4e46a1637598549df1db2de3a87838430f6 /compiler/rustc_borrowck
parente8d9f38141a0ee8ac5484783e1fb5c218f9d2eee (diff)
downloadrust-5a4601fea56502e4f50df046c4205e678397599b.tar.gz
rust-5a4601fea56502e4f50df046c4205e678397599b.zip
use opaque_ty_origin_unchecked instead of destructuring HIR
Diffstat (limited to 'compiler/rustc_borrowck')
-rw-r--r--compiler/rustc_borrowck/src/type_check/mod.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs
index 4776c11e309..508903049db 100644
--- a/compiler/rustc_borrowck/src/type_check/mod.rs
+++ b/compiler/rustc_borrowck/src/type_check/mod.rs
@@ -227,17 +227,9 @@ pub(crate) fn type_check<'mir, 'tcx>(
                     let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
                     // Check that RPITs are only constrained in their outermost
                     // function, otherwise report a mismatched types error.
-                    if let hir::Node::Item(hir::Item {
-                        kind:
-                            hir::ItemKind::OpaqueTy(hir::OpaqueTy {
-                                origin:
-                                    hir::OpaqueTyOrigin::AsyncFn(parent)
-                                    | hir::OpaqueTyOrigin::FnReturn(parent),
-                                ..
-                            }),
-                        ..
-                    }) = infcx.tcx.hir().get_by_def_id(opaque_type_key.def_id.expect_local()) &&
-                        parent.to_def_id() != body.source.def_id()
+                    if let OpaqueTyOrigin::FnReturn(parent) | OpaqueTyOrigin::AsyncFn(parent)
+                            = infcx.opaque_ty_origin_unchecked(opaque_type_key.def_id, hidden_type.span)
+                        && parent.to_def_id() != body.source.def_id()
                     {
                         infcx
                             .report_mismatched_types(
@@ -247,7 +239,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
                                         body.source.def_id().expect_local(),
                                     ),
                                 ),
-                                infcx.tcx.mk_opaque(opaque_type_key.def_id, opaque_type_key.substs),
+                                infcx.tcx.mk_opaque(opaque_type_key.def_id.to_def_id(), opaque_type_key.substs),
                                 hidden_type.ty,
                                 ty::error::TypeError::Mismatch,
                             )