@@ -298,7 +298,8 @@ pub enum AutoRef {
298
298
299
299
/// Convert from T to *T
300
300
/// 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 > > ) ,
302
303
}
303
304
304
305
// 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>) {
326
327
( b, u, Some ( adj_r) )
327
328
}
328
329
}
330
+ & AutoUnsafe ( _, Some ( box ref autoref) ) => autoref_object_region ( autoref) ,
329
331
_ => ( false , false , None )
330
332
}
331
333
}
@@ -380,6 +382,12 @@ pub fn type_of_adjust(cx: &ctxt, adj: &AutoAdjustment) -> Option<t> {
380
382
None => None
381
383
}
382
384
}
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
+ }
383
391
_ => None
384
392
}
385
393
}
@@ -1898,7 +1906,7 @@ pub fn type_is_self(ty: t) -> bool {
1898
1906
1899
1907
fn type_is_slice ( ty : t ) -> bool {
1900
1908
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 {
1902
1910
ty_vec( _, None ) | ty_str => true ,
1903
1911
_ => false ,
1904
1912
} ,
@@ -1996,7 +2004,8 @@ pub fn type_is_unique(ty: t) -> bool {
1996
2004
1997
2005
pub fn type_is_fat_ptr ( cx : & ctxt , ty : t ) -> bool {
1998
2006
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 ,
2000
2009
_ => false ,
2001
2010
}
2002
2011
}
@@ -2896,7 +2905,7 @@ pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability {
2896
2905
2897
2906
pub fn type_is_trait ( ty : t ) -> bool {
2898
2907
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 {
2900
2909
ty_trait( ..) => true ,
2901
2910
_ => false
2902
2911
} ,
@@ -3392,8 +3401,12 @@ pub fn adjust_ty(cx: &ctxt,
3392
3401
} )
3393
3402
}
3394
3403
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} )
3397
3410
}
3398
3411
3399
3412
AutoUnsize ( ref k) => unsize_ty ( cx, ty, k, span) ,
@@ -3444,7 +3457,8 @@ impl AutoRef {
3444
3457
ty:: AutoPtr ( r, m, Some ( ref a) ) => ty:: AutoPtr ( f ( r) , m, Some ( box a. map_region ( f) ) ) ,
3445
3458
ty:: AutoUnsize ( ref k) => ty:: AutoUnsize ( k. clone ( ) ) ,
3446
3459
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) ) ) ,
3448
3462
}
3449
3463
}
3450
3464
}
0 commit comments