@@ -226,7 +226,10 @@ pub enum AutoRef {
226
226
AutoBorrowFn ( Region ) ,
227
227
228
228
/// Convert from T to *T
229
- AutoUnsafe ( ast:: mutability )
229
+ AutoUnsafe ( ast:: mutability ) ,
230
+
231
+ /// Convert from @Trait/~Trait/&Trait to &Trait
232
+ AutoBorrowObj ( Region , ast:: mutability ) ,
230
233
}
231
234
232
235
pub type ctxt = @ctxt_ ;
@@ -1004,7 +1007,13 @@ fn mk_t(cx: ctxt, st: sty) -> t {
1004
1007
& ty_self( _) => flags |= has_self as uint ,
1005
1008
& ty_enum( _, ref substs) | & ty_struct( _, ref substs) |
1006
1009
& ty_trait( _, ref substs, _, _, _) => {
1007
- flags |= sflags ( substs) ;
1010
+ flags |= sflags ( substs) ;
1011
+ match st {
1012
+ ty_trait( _, _, RegionTraitStore ( r) , _, _) => {
1013
+ flags |= rflags ( r) ;
1014
+ }
1015
+ _ => { }
1016
+ }
1008
1017
}
1009
1018
& ty_box( ref m) | & ty_uniq( ref m) | & ty_evec( ref m, _) |
1010
1019
& ty_ptr( ref m) | & ty_unboxed_vec( ref m) => {
@@ -3009,6 +3018,10 @@ pub fn adjust_ty(cx: ctxt,
3009
3018
AutoUnsafe ( m) => {
3010
3019
mk_ptr ( cx, mt { ty : adjusted_ty, mutbl : m} )
3011
3020
}
3021
+
3022
+ AutoBorrowObj ( r, m) => {
3023
+ borrow_obj ( cx, span, r, m, adjusted_ty)
3024
+ }
3012
3025
}
3013
3026
}
3014
3027
}
@@ -3054,6 +3067,22 @@ pub fn adjust_ty(cx: ctxt,
3054
3067
}
3055
3068
}
3056
3069
}
3070
+
3071
+ fn borrow_obj ( cx : ctxt , span : span , r : Region ,
3072
+ m : ast:: mutability , ty : ty:: t ) -> ty:: t {
3073
+ match get ( ty) . sty {
3074
+ ty_trait( trt_did, ref trt_substs, _, _, b) => {
3075
+ ty:: mk_trait ( cx, trt_did, trt_substs. clone ( ) ,
3076
+ RegionTraitStore ( r) , m, b)
3077
+ }
3078
+ ref s => {
3079
+ cx. sess . span_bug (
3080
+ span,
3081
+ fmt ! ( "borrow-trait-obj associated with bad sty: %?" ,
3082
+ s) ) ;
3083
+ }
3084
+ }
3085
+ }
3057
3086
}
3058
3087
3059
3088
impl AutoRef {
@@ -3064,6 +3093,7 @@ impl AutoRef {
3064
3093
ty:: AutoBorrowVecRef ( r, m) => ty:: AutoBorrowVecRef ( f ( r) , m) ,
3065
3094
ty:: AutoBorrowFn ( r) => ty:: AutoBorrowFn ( f ( r) ) ,
3066
3095
ty:: AutoUnsafe ( m) => ty:: AutoUnsafe ( m) ,
3096
+ ty:: AutoBorrowObj ( r, m) => ty:: AutoBorrowObj ( f ( r) , m) ,
3067
3097
}
3068
3098
}
3069
3099
}
0 commit comments