@@ -3064,30 +3064,37 @@ tag copy_action { INIT; DROP_EXISTING; }
3064
3064
3065
3065
fn copy_val( & @block_ctxt cx, copy_action action, ValueRef dst, ValueRef src,
3066
3066
& ty:: t t) -> result {
3067
- if ( ty:: type_is_scalar( cx. fcx. lcx. ccx. tcx, t) ||
3068
- ty:: type_is_native( cx. fcx. lcx. ccx. tcx, t) ) {
3067
+ auto ccx = cx. fcx. lcx. ccx;
3068
+ // FIXME this is just a clunky stopgap. we should do proper checking in an
3069
+ // earlier pass.
3070
+ if ( !ty:: type_is_copyable( ccx. tcx, t) ) {
3071
+ ccx. sess. span_err( cx. sp, "Copying a non-copyable type . ") ;
3072
+ }
3073
+
3074
+ if ( ty:: type_is_scalar( ccx. tcx, t) ||
3075
+ ty:: type_is_native( ccx. tcx, t) ) {
3069
3076
ret rslt( cx, cx. build. Store ( src, dst) ) ;
3070
- } else if ( ty:: type_is_nil( cx . fcx . lcx . ccx. tcx, t) ||
3071
- ty:: type_is_bot( cx . fcx . lcx . ccx. tcx, t) ) {
3077
+ } else if ( ty:: type_is_nil( ccx. tcx, t) ||
3078
+ ty:: type_is_bot( ccx. tcx, t) ) {
3072
3079
ret rslt( cx, C_nil ( ) ) ;
3073
- } else if ( ty:: type_is_boxed( cx . fcx . lcx . ccx. tcx, t) ) {
3080
+ } else if ( ty:: type_is_boxed( ccx. tcx, t) ) {
3074
3081
auto r = take_ty( cx, src, t) ;
3075
3082
if ( action == DROP_EXISTING ) {
3076
3083
r = drop_ty( r. bcx, r. bcx. build. Load ( dst) , t) ;
3077
3084
}
3078
3085
ret rslt( r. bcx, r. bcx. build. Store ( src, dst) ) ;
3079
- } else if ( ty:: type_is_structural( cx . fcx . lcx . ccx. tcx, t) ||
3080
- ty:: type_has_dynamic_size( cx . fcx . lcx . ccx. tcx, t) ) {
3086
+ } else if ( ty:: type_is_structural( ccx. tcx, t) ||
3087
+ ty:: type_has_dynamic_size( ccx. tcx, t) ) {
3081
3088
auto r = take_ty( cx, src, t) ;
3082
3089
if ( action == DROP_EXISTING ) { r = drop_ty( r. bcx, dst, t) ; }
3083
3090
r = memmove_ty( r. bcx, dst, src, t) ;
3084
- if ( ty:: type_owns_heap_mem( cx . fcx . lcx . ccx. tcx, t) ) {
3091
+ if ( ty:: type_owns_heap_mem( ccx. tcx, t) ) {
3085
3092
r = duplicate_heap_parts( cx, dst, t) ;
3086
3093
}
3087
3094
ret r;
3088
3095
}
3089
- cx . fcx . lcx . ccx. sess. bug( "unexpected type in trans:: copy_val: " +
3090
- ty_to_str( cx . fcx . lcx . ccx. tcx, t) ) ;
3096
+ ccx. sess. bug( "unexpected type in trans:: copy_val: " +
3097
+ ty_to_str( ccx. tcx, t) ) ;
3091
3098
}
3092
3099
3093
3100
0 commit comments