@@ -227,17 +227,9 @@ pub(crate) fn type_check<'mir, 'tcx>(
227
227
let mut hidden_type = infcx. resolve_vars_if_possible ( decl. hidden_type ) ;
228
228
// Check that RPITs are only constrained in their outermost
229
229
// function, otherwise report a mismatched types error.
230
- if let hir:: Node :: Item ( hir:: Item {
231
- kind :
232
- hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy {
233
- origin :
234
- hir:: OpaqueTyOrigin :: AsyncFn ( parent)
235
- | hir:: OpaqueTyOrigin :: FnReturn ( parent) ,
236
- ..
237
- } ) ,
238
- ..
239
- } ) = infcx. tcx . hir ( ) . get_by_def_id ( opaque_type_key. def_id . expect_local ( ) ) &&
240
- parent. to_def_id ( ) != body. source . def_id ( )
230
+ if let OpaqueTyOrigin :: FnReturn ( parent) | OpaqueTyOrigin :: AsyncFn ( parent)
231
+ = infcx. opaque_ty_origin_unchecked ( opaque_type_key. def_id , hidden_type. span )
232
+ && parent. to_def_id ( ) != body. source . def_id ( )
241
233
{
242
234
infcx
243
235
. report_mismatched_types (
@@ -247,7 +239,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
247
239
body. source . def_id ( ) . expect_local ( ) ,
248
240
) ,
249
241
) ,
250
- infcx. tcx . mk_opaque ( opaque_type_key. def_id , opaque_type_key. substs ) ,
242
+ infcx. tcx . mk_opaque ( opaque_type_key. def_id . to_def_id ( ) , opaque_type_key. substs ) ,
251
243
hidden_type. ty ,
252
244
ty:: error:: TypeError :: Mismatch ,
253
245
)
0 commit comments