@@ -42,9 +42,8 @@ fn is_stable(
42
42
}
43
43
}
44
44
45
- /// Determine whether this type may have a reference in it, recursing below compound types but
46
- /// not below references.
47
- fn may_have_reference < ' tcx > ( ty : Ty < ' tcx > , tcx : TyCtxt < ' tcx > ) -> bool {
45
+ /// Determine whether this type may be a reference (or box), and thus needs retagging.
46
+ fn may_be_reference < ' tcx > ( ty : Ty < ' tcx > ) -> bool {
48
47
match ty. sty {
49
48
// Primitive types that are not references
50
49
ty:: Bool | ty:: Char |
@@ -55,15 +54,12 @@ fn may_have_reference<'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> bool {
55
54
// References
56
55
ty:: Ref ( ..) => true ,
57
56
ty:: Adt ( ..) if ty. is_box ( ) => true ,
58
- // Compound types
59
- ty:: Array ( ty, ..) | ty:: Slice ( ty) =>
60
- may_have_reference ( ty, tcx) ,
61
- ty:: Tuple ( tys) =>
62
- tys. iter ( ) . any ( |ty| may_have_reference ( ty. expect_ty ( ) , tcx) ) ,
63
- ty:: Adt ( adt, substs) =>
64
- adt. variants . iter ( ) . any ( |v| v. fields . iter ( ) . any ( |f|
65
- may_have_reference ( f. ty ( tcx, substs) , tcx)
66
- ) ) ,
57
+ // Compound types are not references
58
+ ty:: Array ( ..) |
59
+ ty:: Slice ( ..) |
60
+ ty:: Tuple ( ..) |
61
+ ty:: Adt ( ..) =>
62
+ false ,
67
63
// Conservative fallback
68
64
_ => true ,
69
65
}
@@ -80,7 +76,7 @@ impl MirPass for AddRetag {
80
76
// FIXME: Instead of giving up for unstable places, we should introduce
81
77
// a temporary and retag on that.
82
78
is_stable ( place. as_ref ( ) )
83
- && may_have_reference ( place. ty ( & * local_decls, tcx) . ty , tcx )
79
+ && may_be_reference ( place. ty ( & * local_decls, tcx) . ty )
84
80
} ;
85
81
86
82
// PART 1
0 commit comments