@@ -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 (
@@ -914,11 +904,11 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
914904 }
915905
916906 fn get_anon_bound_ty ( self , id : usize ) -> Option < Vec < Ty < ' tcx > > > {
917- self . types . anon_bound_tys . get ( id) . copied ( )
907+ self . types . anon_bound_tys . get ( id) . cloned ( )
918908 }
919909
920910 fn get_anon_canonical_bound_ty ( self , id : usize ) -> Option < Ty < ' tcx > > {
921- self . types . anon_canonical_bound_tys . get ( id. as_usize ( ) ) . copied ( )
911+ self . types . anon_canonical_bound_tys . get ( id) . copied ( )
922912 }
923913
924914 fn get_generic_args_for_item (
@@ -1052,6 +1042,19 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
10521042 let context_ty = Ty :: new_adt ( self , context_adt_ref, context_args) ;
10531043 Ty :: new_mut_ref ( self , self . lifetimes . re_erased , context_ty)
10541044 }
1045+
1046+ fn new_fn_def (
1047+ self ,
1048+ def_id : DefId ,
1049+ args : impl IntoIterator < Item : Into < ty:: GenericArg < ' tcx > > > ,
1050+ ) -> Ty < ' tcx > {
1051+ debug_assert_matches ! (
1052+ self . def_kind( def_id) ,
1053+ DefKind :: AssocFn | DefKind :: Fn | DefKind :: Ctor ( _, CtorKind :: Fn )
1054+ ) ;
1055+ let args = self . check_and_mk_args ( def_id, args) ;
1056+ Ty :: new ( self , ty:: FnDef ( def_id, args) )
1057+ }
10551058}
10561059
10571060/// Defines trivial conversion functions between the main [`LangItem`] enum,
0 commit comments