@@ -113,15 +113,16 @@ pub fn immediate_rvalue_bcx<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
113
113
/// it. The memory will be dropped upon exit from `scope`. The callback `populate` should
114
114
/// initialize the memory. If `zero` is true, the space will be zeroed when it is allocated; this
115
115
/// is not necessary unless `bcx` does not dominate the end of `scope`.
116
- pub fn lvalue_scratch_datum < ' blk , ' tcx , A > ( bcx : Block < ' blk , ' tcx > ,
117
- ty : Ty < ' tcx > ,
118
- name : & str ,
119
- zero : bool ,
120
- scope : cleanup:: ScopeId ,
121
- arg : A ,
122
- populate : |A , Block < ' blk , ' tcx > , ValueRef |
123
- -> Block < ' blk , ' tcx > )
124
- -> DatumBlock < ' blk , ' tcx , Lvalue > {
116
+ pub fn lvalue_scratch_datum < ' blk , ' tcx , A , F > ( bcx : Block < ' blk , ' tcx > ,
117
+ ty : Ty < ' tcx > ,
118
+ name : & str ,
119
+ zero : bool ,
120
+ scope : cleanup:: ScopeId ,
121
+ arg : A ,
122
+ populate : F )
123
+ -> DatumBlock < ' blk , ' tcx , Lvalue > where
124
+ F : FnOnce ( A , Block < ' blk , ' tcx > , ValueRef ) -> Block < ' blk , ' tcx > ,
125
+ {
125
126
let scratch = if zero {
126
127
alloca_zeroed ( bcx, ty, name)
127
128
} else {
@@ -339,10 +340,10 @@ impl<'tcx> Datum<'tcx, Rvalue> {
339
340
/// here since we can `match self.kind` rather than having to implement
340
341
/// generic methods in `KindOps`.)
341
342
impl < ' tcx > Datum < ' tcx , Expr > {
342
- fn match_kind < R > ( self ,
343
- if_lvalue : | Datum < ' tcx , Lvalue > | -> R ,
344
- if_rvalue : | Datum < ' tcx , Rvalue > | -> R )
345
- -> R {
343
+ fn match_kind < R , F , G > ( self , if_lvalue : F , if_rvalue : G ) -> R where
344
+ F : FnOnce ( Datum < ' tcx , Lvalue > ) -> R ,
345
+ G : FnOnce ( Datum < ' tcx , Rvalue > ) -> R ,
346
+ {
346
347
let Datum { val, ty, kind } = self ;
347
348
match kind {
348
349
LvalueExpr => if_lvalue ( Datum :: new ( val, ty, Lvalue ) ) ,
@@ -455,9 +456,11 @@ impl<'tcx> Datum<'tcx, Lvalue> {
455
456
// datum may also be unsized _without the size information_. It is the
456
457
// callers responsibility to package the result in some way to make a valid
457
458
// datum in that case (e.g., by making a fat pointer or opened pair).
458
- pub fn get_element < ' blk > ( & self , bcx : Block < ' blk , ' tcx > , ty : Ty < ' tcx > ,
459
- gep: |ValueRef | -> ValueRef )
460
- -> Datum < ' tcx , Lvalue > {
459
+ pub fn get_element < ' blk , F > ( & self , bcx : Block < ' blk , ' tcx > , ty : Ty < ' tcx > ,
460
+ gep : F )
461
+ -> Datum < ' tcx , Lvalue > where
462
+ F : FnOnce ( ValueRef ) -> ValueRef ,
463
+ {
461
464
let val = match self . ty . sty {
462
465
_ if ty:: type_is_sized ( bcx. tcx ( ) , self . ty ) => gep ( self . val ) ,
463
466
ty:: ty_open( _) => {
0 commit comments