@@ -188,7 +188,7 @@ pub fn scratch_datum(bcx: block, ty: ty::t, zero: bool) -> Datum {
188
188
Datum { val : scratch, ty : ty, mode : ByRef ( RevokeClean ) }
189
189
}
190
190
191
- pub fn appropriate_mode ( ty : ty:: t ) -> DatumMode {
191
+ pub fn appropriate_mode ( tcx : ty :: ctxt , ty : ty:: t ) -> DatumMode {
192
192
/*!
193
193
*
194
194
* Indicates the "appropriate" mode for this value,
@@ -197,7 +197,7 @@ pub fn appropriate_mode(ty: ty::t) -> DatumMode {
197
197
198
198
if ty:: type_is_nil ( ty) || ty:: type_is_bot ( ty) {
199
199
ByValue
200
- } else if ty:: type_is_immediate ( ty) {
200
+ } else if ty:: type_is_immediate ( tcx , ty) {
201
201
ByValue
202
202
} else {
203
203
ByRef ( RevokeClean )
@@ -508,18 +508,18 @@ impl Datum {
508
508
}
509
509
}
510
510
511
- pub fn appropriate_mode ( & self ) -> DatumMode {
511
+ pub fn appropriate_mode ( & self , tcx : ty :: ctxt ) -> DatumMode {
512
512
/*! See the `appropriate_mode()` function */
513
513
514
- appropriate_mode ( self . ty )
514
+ appropriate_mode ( tcx , self . ty )
515
515
}
516
516
517
517
pub fn to_appropriate_llval ( & self , bcx : block ) -> ValueRef {
518
518
/*!
519
519
*
520
520
* Yields an llvalue with the `appropriate_mode()`. */
521
521
522
- match self . appropriate_mode ( ) {
522
+ match self . appropriate_mode ( bcx . tcx ( ) ) {
523
523
ByValue => self . to_value_llval ( bcx) ,
524
524
ByRef ( _) => self . to_ref_llval ( bcx)
525
525
}
@@ -530,7 +530,7 @@ impl Datum {
530
530
*
531
531
* Yields a datum with the `appropriate_mode()`. */
532
532
533
- match self . appropriate_mode ( ) {
533
+ match self . appropriate_mode ( bcx . tcx ( ) ) {
534
534
ByValue => self . to_value_datum ( bcx) ,
535
535
ByRef ( _) => self . to_ref_datum ( bcx)
536
536
}
@@ -657,13 +657,7 @@ impl Datum {
657
657
ByValue => {
658
658
// Actually, this case cannot happen right
659
659
// now, because enums are never immediate.
660
- // But in principle newtype'd immediate
661
- // values should be immediate, and in that
662
- // case the * would be a no-op except for
663
- // changing the type, so I am putting this
664
- // code in place here to do the right
665
- // thing if this change ever goes through.
666
- assert ! ( ty:: type_is_immediate( ty) ) ;
660
+ assert ! ( ty:: type_is_immediate( bcx. tcx( ) , ty) ) ;
667
661
( Some ( Datum { ty : ty, ..* self } ) , bcx)
668
662
}
669
663
} ;
@@ -695,15 +689,15 @@ impl Datum {
695
689
)
696
690
}
697
691
ByValue => {
698
- // Actually, this case cannot happen right now,
699
- // because structs are never immediate. But in
700
- // principle, newtype'd immediate values should be
701
- // immediate, and in that case the * would be a no-op
702
- // except for changing the type, so I am putting this
703
- // code in place here to do the right thing if this
704
- // change ever goes through.
705
- assert ! ( ty :: type_is_immediate ( ty ) ) ;
706
- ( Some ( Datum { ty : ty , .. * self } ) , bcx )
692
+ assert ! ( ty :: type_is_immediate ( bcx . tcx ( ) , ty ) ) ;
693
+ (
694
+ Some ( Datum {
695
+ val : ExtractValue ( bcx , self . val , 0 ) ,
696
+ ty : ty ,
697
+ mode : ByValue
698
+ } ) ,
699
+ bcx
700
+ )
707
701
}
708
702
}
709
703
}
0 commit comments