File tree 2 files changed +39
-7
lines changed
compiler/rustc_middle/src/ty
2 files changed +39
-7
lines changed Original file line number Diff line number Diff line change @@ -1362,13 +1362,6 @@ impl CurrentGcx {
1362
1362
1363
1363
impl < ' tcx > TyCtxt < ' tcx > {
1364
1364
pub fn has_typeck_results ( self , def_id : LocalDefId ) -> bool {
1365
- // Closures' typeck results come from their outermost function,
1366
- // as they are part of the same "inference environment".
1367
- let typeck_root_def_id = self . typeck_root_def_id ( def_id. to_def_id ( ) ) ;
1368
- if typeck_root_def_id != def_id. to_def_id ( ) {
1369
- return self . has_typeck_results ( typeck_root_def_id. expect_local ( ) ) ;
1370
- }
1371
-
1372
1365
self . hir_node_by_def_id ( def_id) . body_id ( ) . is_some ( )
1373
1366
}
1374
1367
Original file line number Diff line number Diff line change @@ -602,6 +602,45 @@ impl<'tcx> TyCtxt<'tcx> {
602
602
/// `typeck` the closure, for example, we really wind up
603
603
/// fetching the `typeck` the enclosing fn item.
604
604
pub fn typeck_root_def_id ( self , def_id : DefId ) -> DefId {
605
+ // It only really makes sense to call this for a body that is typeck'd.
606
+ if cfg ! ( debug_assertions) {
607
+ match self . def_kind ( def_id) {
608
+ DefKind :: Fn
609
+ | DefKind :: Const
610
+ | DefKind :: Static { .. }
611
+ | DefKind :: Ctor ( ..)
612
+ | DefKind :: AssocFn
613
+ | DefKind :: AssocConst
614
+ | DefKind :: AnonConst
615
+ | DefKind :: InlineConst
616
+ | DefKind :: Closure => { }
617
+ kind @ ( DefKind :: Mod
618
+ | DefKind :: Struct
619
+ | DefKind :: Union
620
+ | DefKind :: Enum
621
+ | DefKind :: Variant
622
+ | DefKind :: Trait
623
+ | DefKind :: TyAlias
624
+ | DefKind :: ForeignTy
625
+ | DefKind :: TraitAlias
626
+ | DefKind :: AssocTy
627
+ | DefKind :: TyParam
628
+ | DefKind :: ConstParam
629
+ | DefKind :: Macro ( _)
630
+ | DefKind :: ExternCrate
631
+ | DefKind :: Use
632
+ | DefKind :: ForeignMod
633
+ | DefKind :: OpaqueTy
634
+ | DefKind :: Field
635
+ | DefKind :: LifetimeParam
636
+ | DefKind :: GlobalAsm
637
+ | DefKind :: Impl { .. }
638
+ | DefKind :: SyntheticCoroutineBody ) => {
639
+ bug ! ( "unexpected typeck_root_def_id call for {def_id:?} ({kind:?})" ) ;
640
+ }
641
+ }
642
+ }
643
+
605
644
let mut def_id = def_id;
606
645
while self . is_typeck_child ( def_id) {
607
646
def_id = self . parent ( def_id) ;
You can’t perform that action at this time.
0 commit comments