@@ -893,13 +893,10 @@ pub enum TyKind {
893
893
#[ custom_arm(
894
894
ty:: TyKind :: Closure ( def_id, generics) => {
895
895
let closure = generics. as_closure( ) ;
896
- TyKind :: Closure (
897
- def_id. sinto( s) ,
898
- ClosureArgs :: sfrom( s, * def_id, closure) ,
899
- )
896
+ TyKind :: Closure ( ClosureArgs :: sfrom( s, * def_id, closure) )
900
897
} ,
901
898
) ]
902
- Closure ( DefId , ClosureArgs ) ,
899
+ Closure ( ClosureArgs ) ,
903
900
904
901
#[ custom_arm( FROM_TYPE :: Adt ( adt_def, generics) => TO_TYPE :: Adt ( translate_item_ref( s, adt_def. did( ) , generics) ) , ) ]
905
902
Adt ( ItemRef ) ,
@@ -1352,11 +1349,10 @@ pub enum AliasRelationDirection {
1352
1349
#[ derive( Clone , Debug , Hash , PartialEq , Eq , PartialOrd , Ord , JsonSchema ) ]
1353
1350
#[ derive_group( Serializers ) ]
1354
1351
pub struct ClosureArgs {
1352
+ pub item : ItemRef ,
1355
1353
/// The base kind of this closure. The kinds are ordered by inclusion: any `Fn` works as an
1356
1354
/// `FnMut`, and any `FnMut` works as an `FnOnce`.
1357
1355
pub kind : ClosureKind ,
1358
- /// Reference to the item which contains the closure.
1359
- pub parent : ItemRef ,
1360
1356
/// The proper `fn(A, B, C) -> D` signature of the closure.
1361
1357
pub untupled_sig : PolyFnSig ,
1362
1358
/// The signature of the closure as one input and one output, where the input arguments are
@@ -1379,13 +1375,15 @@ impl ClosureArgs {
1379
1375
{
1380
1376
let tcx = s. base ( ) . tcx ;
1381
1377
let sig = from. sig ( ) ;
1378
+ let item = {
1379
+ // The closure has no generics of its own: it inherits its parent generics and could
1380
+ // have late-bound args but these are part of the signature.
1381
+ let parent_args = tcx. mk_args ( from. parent_args ( ) ) ;
1382
+ translate_item_ref ( s, def_id, parent_args)
1383
+ } ;
1382
1384
ClosureArgs {
1385
+ item,
1383
1386
kind : from. kind ( ) . sinto ( s) ,
1384
- parent : {
1385
- let parent_id = tcx. generics_of ( def_id) . parent . unwrap ( ) ;
1386
- let parent_args = tcx. mk_args ( from. parent_args ( ) ) ;
1387
- translate_item_ref ( s, parent_id, parent_args)
1388
- } ,
1389
1387
tupled_sig : sig. sinto ( s) ,
1390
1388
untupled_sig : tcx
1391
1389
. signature_unclosure ( sig, rustc_hir:: Safety :: Safe )
0 commit comments