@@ -141,7 +141,7 @@ impl<'tcx> GotocCtx<'tcx> {
141
141
/// }
142
142
/// Ensures that the vtable is added to the symbol table.
143
143
fn codegen_trait_vtable_type ( & mut self , t : & ' tcx ty:: TyS < ' tcx > ) -> Type {
144
- self . ensure_struct ( & self . vtable_name ( t) , |ctx, name | ctx. trait_vtable_field_types ( t) )
144
+ self . ensure_struct ( & self . vtable_name ( t) , |ctx, _ | ctx. trait_vtable_field_types ( t) )
145
145
}
146
146
147
147
/// a trait dyn Trait is translated to
@@ -150,7 +150,7 @@ impl<'tcx> GotocCtx<'tcx> {
150
150
/// void* vtable;
151
151
/// }
152
152
fn codegen_trait_fat_ptr_type ( & mut self , t : & ' tcx ty:: TyS < ' tcx > ) -> Type {
153
- self . ensure_struct ( & self . normalized_trait_name ( t) , |ctx, name | {
153
+ self . ensure_struct ( & self . normalized_trait_name ( t) , |ctx, _ | {
154
154
// At this point in time, the vtable hasn't been codegen yet.
155
155
// However, all we need to know is its name, which we do know.
156
156
// See the comment on codegen_ty_ref.
@@ -313,7 +313,7 @@ impl<'tcx> GotocCtx<'tcx> {
313
313
// struct [T; n] {
314
314
// T _0[n];
315
315
// }
316
- self . ensure_struct ( & array_name, |ctx, name | {
316
+ self . ensure_struct ( & array_name, |ctx, _ | {
317
317
if et. is_unit ( ) {
318
318
// we do not generate a struct with an array of units
319
319
vec ! [ ]
@@ -347,8 +347,8 @@ impl<'tcx> GotocCtx<'tcx> {
347
347
} else {
348
348
// we do not have to do two insertions for tuple because it is impossible for
349
349
// finite tuples to loop.
350
- self . ensure_struct ( & self . ty_mangled_name ( ty) , |tcx, name | {
351
- tcx. codegen_ty_tuple_fields ( name , ty, ts)
350
+ self . ensure_struct ( & self . ty_mangled_name ( ty) , |tcx, _ | {
351
+ tcx. codegen_ty_tuple_fields ( ty, ts)
352
352
} )
353
353
}
354
354
}
@@ -392,11 +392,10 @@ impl<'tcx> GotocCtx<'tcx> {
392
392
393
393
fn codegen_ty_tuple_fields (
394
394
& mut self ,
395
- name : & str ,
396
395
t : Ty < ' tcx > ,
397
396
substs : ty:: subst:: SubstsRef < ' tcx > ,
398
397
) -> Vec < DatatypeComponent > {
399
- self . codegen_ty_tuple_like ( name , t, substs. iter ( ) . map ( |g| g. expect_ty ( ) ) . collect ( ) )
398
+ self . codegen_ty_tuple_like ( t, substs. iter ( ) . map ( |g| g. expect_ty ( ) ) . collect ( ) )
400
399
}
401
400
402
401
fn codegen_struct_padding < T > (
@@ -434,7 +433,6 @@ impl<'tcx> GotocCtx<'tcx> {
434
433
/// * initial_offset - offset which has been accumulated in parent struct, in bits
435
434
fn codegen_struct_fields (
436
435
& mut self ,
437
- name : & str ,
438
436
flds : Vec < ( String , Ty < ' tcx > ) > ,
439
437
layout : & Layout ,
440
438
initial_offset : usize ,
@@ -492,25 +490,19 @@ impl<'tcx> GotocCtx<'tcx> {
492
490
}
493
491
}
494
492
495
- fn codegen_ty_tuple_like (
496
- & mut self ,
497
- name : & str ,
498
- t : Ty < ' tcx > ,
499
- tys : Vec < Ty < ' tcx > > ,
500
- ) -> Vec < DatatypeComponent > {
493
+ fn codegen_ty_tuple_like ( & mut self , t : Ty < ' tcx > , tys : Vec < Ty < ' tcx > > ) -> Vec < DatatypeComponent > {
501
494
let layout = self . layout_of ( t) ;
502
495
let flds: Vec < _ > = tys. iter ( ) . enumerate ( ) . map ( |( i, t) | ( tuple_fld ( i) , * t) ) . collect ( ) ;
503
496
// tuple cannot have other initial offset
504
- self . codegen_struct_fields ( name , flds, layout. layout , 0 )
497
+ self . codegen_struct_fields ( flds, layout. layout , 0 )
505
498
}
506
499
507
500
/// a closure is a struct of all its environments
508
501
/// that is, a closure is just a tuple with a unique type identifier, so that Fn related traits
509
502
/// can find its impl.
510
503
fn codegen_ty_closure ( & mut self , t : Ty < ' tcx > , substs : ty:: subst:: SubstsRef < ' tcx > ) -> Type {
511
- let name = self . ty_mangled_name ( t) ;
512
- self . ensure_struct ( & name, |ctx, name| {
513
- ctx. codegen_ty_tuple_like ( name, t, substs. as_closure ( ) . upvar_tys ( ) . collect ( ) )
504
+ self . ensure_struct ( & self . ty_mangled_name ( t) , |ctx, _| {
505
+ ctx. codegen_ty_tuple_like ( t, substs. as_closure ( ) . upvar_tys ( ) . collect ( ) )
514
506
} )
515
507
}
516
508
@@ -524,7 +516,7 @@ impl<'tcx> GotocCtx<'tcx> {
524
516
ty:: Adt ( ..) if self . is_unsized ( t) => {
525
517
// https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp
526
518
let fat_ptr_name = format ! ( "&{}" , self . ty_mangled_name( t) ) ;
527
- self . ensure_struct ( & fat_ptr_name, |ctx, name | {
519
+ self . ensure_struct ( & fat_ptr_name, |ctx, _ | {
528
520
vec ! [
529
521
Type :: datatype_component( "data" , ctx. codegen_ty( t) . to_pointer( ) ) ,
530
522
Type :: datatype_component( "len" , Type :: size_t( ) ) ,
@@ -666,17 +658,16 @@ impl<'tcx> GotocCtx<'tcx> {
666
658
def : & ' tcx AdtDef ,
667
659
subst : & ' tcx InternalSubsts < ' tcx > ,
668
660
) -> Type {
669
- self . ensure_struct ( & self . ty_mangled_name ( ty) , |ctx, name | {
661
+ self . ensure_struct ( & self . ty_mangled_name ( ty) , |ctx, _ | {
670
662
let variant = & def. variants . raw [ 0 ] ;
671
663
let layout = ctx. layout_of ( ty) ;
672
- ctx. codegen_variant_struct_fields ( name , variant, subst, layout. layout , 0 )
664
+ ctx. codegen_variant_struct_fields ( variant, subst, layout. layout , 0 )
673
665
} )
674
666
}
675
667
676
668
/// generate a struct representing the layout of the variant
677
669
fn codegen_variant_struct_fields (
678
670
& mut self ,
679
- name : & str ,
680
671
variant : & VariantDef ,
681
672
subst : & ' tcx InternalSubsts < ' tcx > ,
682
673
layout : & Layout ,
@@ -687,7 +678,7 @@ impl<'tcx> GotocCtx<'tcx> {
687
678
. iter ( )
688
679
. map ( |f| ( f. ident . name . to_string ( ) , f. ty ( self . tcx , subst) ) )
689
680
. collect ( ) ;
690
- self . codegen_struct_fields ( name , flds, layout, initial_offset)
681
+ self . codegen_struct_fields ( flds, layout, initial_offset)
691
682
}
692
683
693
684
/// codegen unions
@@ -697,7 +688,7 @@ impl<'tcx> GotocCtx<'tcx> {
697
688
def : & ' tcx AdtDef ,
698
689
subst : & ' tcx InternalSubsts < ' tcx > ,
699
690
) -> Type {
700
- self . ensure_union ( & self . ty_mangled_name ( ty) , |ctx, name | {
691
+ self . ensure_union ( & self . ty_mangled_name ( ty) , |ctx, _ | {
701
692
def. variants . raw [ 0 ]
702
693
. fields
703
694
. iter ( )
@@ -763,7 +754,7 @@ impl<'tcx> GotocCtx<'tcx> {
763
754
Some ( variant) => {
764
755
// a single enum is pretty much like a struct
765
756
let layout = ctx. layout_of ( ty) . layout ;
766
- ctx. codegen_variant_struct_fields ( name , variant, subst, layout, 0 )
757
+ ctx. codegen_variant_struct_fields ( variant, subst, layout, 0 )
767
758
}
768
759
}
769
760
}
@@ -804,7 +795,6 @@ impl<'tcx> GotocCtx<'tcx> {
804
795
// dataful_variant is pretty much the only variant which contains the valid data
805
796
let variant = & adtdef. variants [ * dataful_variant] ;
806
797
ctx. codegen_variant_struct_fields (
807
- name,
808
798
variant,
809
799
subst,
810
800
& variants[ * dataful_variant] ,
@@ -923,7 +913,7 @@ impl<'tcx> GotocCtx<'tcx> {
923
913
let case_name = format ! ( "{}::{}" , name, case. ident. name) ;
924
914
debug ! ( "handling variant {}: {:?}" , case_name, case) ;
925
915
self . ensure_struct ( & case_name, |tcx, _| {
926
- tcx. codegen_variant_struct_fields ( & case_name , case, subst, variant, initial_offset)
916
+ tcx. codegen_variant_struct_fields ( case, subst, variant, initial_offset)
927
917
} )
928
918
}
929
919
0 commit comments