@@ -312,18 +312,8 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
312312 }
313313 }
314314
315- /// Given the `DefId`, returns the `DefId` of the innermost item that
316- /// has its own type-checking context or "inference environment".
317- ///
318- /// For example, a closure has its own `DefId`, but it is type-checked
319- /// with the containing item. Therefore, when we fetch the `typeck` of the closure,
320- /// for example, we really wind up fetching the `typeck` of the enclosing fn item.
321315 fn typeck_root_def_id ( self , def_id : DefId ) -> DefId {
322- let mut def_id = def_id;
323- while self . is_typeck_child ( def_id) {
324- def_id = self . parent ( def_id) ;
325- }
326- def_id
316+ self . typeck_root_def_id ( def_id)
327317 }
328318
329319 fn debug_assert_new_dynamic_compatible (
@@ -909,11 +899,11 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
909899 }
910900
911901 fn get_anon_bound_ty ( self , id : usize ) -> Option < Vec < Ty < ' tcx > > > {
912- self . types . anon_bound_tys . get ( id) . copied ( )
902+ self . types . anon_bound_tys . get ( id) . cloned ( )
913903 }
914904
915905 fn get_anon_canonical_bound_ty ( self , id : usize ) -> Option < Ty < ' tcx > > {
916- self . types . anon_canonical_bound_tys . get ( id. as_usize ( ) ) . copied ( )
906+ self . types . anon_canonical_bound_tys . get ( id) . copied ( )
917907 }
918908
919909 fn get_generic_args_for_item (
@@ -1047,6 +1037,19 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
10471037 let context_ty = Ty :: new_adt ( self , context_adt_ref, context_args) ;
10481038 Ty :: new_mut_ref ( self , self . lifetimes . re_erased , context_ty)
10491039 }
1040+
1041+ fn new_fn_def (
1042+ self ,
1043+ def_id : DefId ,
1044+ args : impl IntoIterator < Item : Into < ty:: GenericArg < ' tcx > > > ,
1045+ ) -> Ty < ' tcx > {
1046+ debug_assert_matches ! (
1047+ self . def_kind( def_id) ,
1048+ DefKind :: AssocFn | DefKind :: Fn | DefKind :: Ctor ( _, CtorKind :: Fn )
1049+ ) ;
1050+ let args = self . check_and_mk_args ( def_id, args) ;
1051+ Ty :: new ( self , ty:: FnDef ( def_id, args) )
1052+ }
10501053}
10511054
10521055/// Defines trivial conversion functions between the main [`LangItem`] enum,
0 commit comments