@@ -2022,13 +2022,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2022
2022
if ty::has_dtor(cx, did) {
2023
2023
res += TC_DTOR;
2024
2024
}
2025
- if has_attr(cx, did, " mutable") {
2026
- res += TC_MUTABLE;
2027
- }
2028
- if has_attr(cx, did, " non_owned") {
2029
- res += TC_NON_OWNED;
2030
- }
2031
- res
2025
+ apply_tc_attr(cx, did, res)
2032
2026
}
2033
2027
2034
2028
ty_tup(ref tys) => {
@@ -2037,7 +2031,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2037
2031
2038
2032
ty_enum(did, ref substs) => {
2039
2033
let variants = substd_enum_variants(cx, did, substs);
2040
- let mut res = if variants.is_empty() {
2034
+ let res = if variants.is_empty() {
2041
2035
// we somewhat arbitrary declare that empty enums
2042
2036
// are non-copyable
2043
2037
TC_EMPTY_ENUM
@@ -2048,13 +2042,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2048
2042
|tc, arg_ty| *tc + tc_ty(cx, *arg_ty, cache))
2049
2043
})
2050
2044
};
2051
- if has_attr(cx, did, " mutable") {
2052
- res += TC_MUTABLE;
2053
- }
2054
- if has_attr(cx, did, " non_owned") {
2055
- res += TC_NON_OWNED;
2056
- }
2057
- res
2045
+ apply_tc_attr(cx, did, res)
2058
2046
}
2059
2047
2060
2048
ty_param(p) => {
@@ -2114,6 +2102,16 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2114
2102
mc + tc_ty(cx, mt.ty, cache)
2115
2103
}
2116
2104
2105
+ fn apply_tc_attr(cx: ctxt, did: def_id, mut tc: TypeContents) -> TypeContents {
2106
+ if has_attr(cx, did, " mutable") {
2107
+ tc += TC_MUTABLE;
2108
+ }
2109
+ if has_attr(cx, did, " non_owned") {
2110
+ tc += TC_NON_OWNED;
2111
+ }
2112
+ tc
2113
+ }
2114
+
2117
2115
fn borrowed_contents(region: ty::Region,
2118
2116
mutbl: ast::mutability) -> TypeContents
2119
2117
{
0 commit comments