File tree Expand file tree Collapse file tree 2 files changed +39
-7
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 2 files changed +39
-7
lines changed Original file line number Diff line number Diff line change @@ -1362,13 +1362,6 @@ impl CurrentGcx {
13621362
13631363impl < ' tcx > TyCtxt < ' tcx > {
13641364 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-
13721365 self . hir_node_by_def_id ( def_id) . body_id ( ) . is_some ( )
13731366 }
13741367
Original file line number Diff line number Diff line change @@ -602,6 +602,45 @@ impl<'tcx> TyCtxt<'tcx> {
602602 /// `typeck` the closure, for example, we really wind up
603603 /// fetching the `typeck` the enclosing fn item.
604604 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+
605644 let mut def_id = def_id;
606645 while self . is_typeck_child ( def_id) {
607646 def_id = self . parent ( def_id) ;
You can’t perform that action at this time.
0 commit comments