@@ -298,7 +298,8 @@ pub enum AutoRef {
298298
299299 /// Convert from T to *T
300300 /// Value to thin pointer
301- AutoUnsafe ( ast:: Mutability ) ,
301+ /// The second field allows us to wrap other AutoRef adjustments.
302+ AutoUnsafe ( ast:: Mutability , Option < Box < AutoRef > > ) ,
302303}
303304
304305// Ugly little helper function. The first bool in the returned tuple is true if
@@ -326,6 +327,7 @@ fn autoref_object_region(autoref: &AutoRef) -> (bool, bool, Option<Region>) {
326327 ( b, u, Some ( adj_r) )
327328 }
328329 }
330+ & AutoUnsafe ( _, Some ( box ref autoref) ) => autoref_object_region ( autoref) ,
329331 _ => ( false , false , None )
330332 }
331333}
@@ -380,6 +382,12 @@ pub fn type_of_adjust(cx: &ctxt, adj: &AutoAdjustment) -> Option<t> {
380382 None => None
381383 }
382384 }
385+ & AutoUnsafe ( m, Some ( box ref autoref) ) => {
386+ match type_of_autoref ( cx, autoref) {
387+ Some ( t) => Some ( mk_ptr ( cx, mt { mutbl : m, ty : t} ) ) ,
388+ None => None
389+ }
390+ }
383391 _ => None
384392 }
385393 }
@@ -1898,7 +1906,7 @@ pub fn type_is_self(ty: t) -> bool {
18981906
18991907fn type_is_slice ( ty : t ) -> bool {
19001908 match get ( ty) . sty {
1901- ty_rptr( _, mt) => match get ( mt. ty ) . sty {
1909+ ty_ptr ( mt ) | ty_rptr( _, mt) => match get ( mt. ty ) . sty {
19021910 ty_vec( _, None ) | ty_str => true ,
19031911 _ => false ,
19041912 } ,
@@ -1996,7 +2004,8 @@ pub fn type_is_unique(ty: t) -> bool {
19962004
19972005pub fn type_is_fat_ptr ( cx : & ctxt , ty : t ) -> bool {
19982006 match get ( ty) . sty {
1999- ty_rptr( _, mt { ty, ..} ) | ty_uniq( ty) if !type_is_sized ( cx, ty) => true ,
2007+ ty_ptr( mt { ty, ..} ) | ty_rptr( _, mt { ty, ..} )
2008+ | ty_uniq( ty) if !type_is_sized ( cx, ty) => true ,
20002009 _ => false ,
20012010 }
20022011}
@@ -2896,7 +2905,7 @@ pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability {
28962905
28972906pub fn type_is_trait ( ty : t ) -> bool {
28982907 match get ( ty) . sty {
2899- ty_uniq( ty) | ty_rptr( _, mt { ty, ..} ) => match get ( ty) . sty {
2908+ ty_uniq( ty) | ty_rptr( _, mt { ty, ..} ) | ty_ptr ( mt { ty , .. } ) => match get ( ty) . sty {
29002909 ty_trait( ..) => true ,
29012910 _ => false
29022911 } ,
@@ -3392,8 +3401,12 @@ pub fn adjust_ty(cx: &ctxt,
33923401 } )
33933402 }
33943403
3395- AutoUnsafe ( m) => {
3396- mk_ptr ( cx, mt { ty : ty, mutbl : m} )
3404+ AutoUnsafe ( m, ref a) => {
3405+ let adjusted_ty = match a {
3406+ & Some ( box ref a) => adjust_for_autoref ( cx, span, ty, a) ,
3407+ & None => ty
3408+ } ;
3409+ mk_ptr ( cx, mt { ty : adjusted_ty, mutbl : m} )
33973410 }
33983411
33993412 AutoUnsize ( ref k) => unsize_ty ( cx, ty, k, span) ,
@@ -3444,7 +3457,8 @@ impl AutoRef {
34443457 ty:: AutoPtr ( r, m, Some ( ref a) ) => ty:: AutoPtr ( f ( r) , m, Some ( box a. map_region ( f) ) ) ,
34453458 ty:: AutoUnsize ( ref k) => ty:: AutoUnsize ( k. clone ( ) ) ,
34463459 ty:: AutoUnsizeUniq ( ref k) => ty:: AutoUnsizeUniq ( k. clone ( ) ) ,
3447- ty:: AutoUnsafe ( m) => ty:: AutoUnsafe ( m) ,
3460+ ty:: AutoUnsafe ( m, None ) => ty:: AutoUnsafe ( m, None ) ,
3461+ ty:: AutoUnsafe ( m, Some ( ref a) ) => ty:: AutoUnsafe ( m, Some ( box a. map_region ( f) ) ) ,
34483462 }
34493463 }
34503464}
0 commit comments