@@ -2063,20 +2063,8 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2063
2063
TC_MANAGED + statically_sized ( nonowned ( tc_mt ( cx, mt, cache) ) )
2064
2064
}
2065
2065
2066
- ty_trait( _, _, UniqTraitStore , _, _bounds) => {
2067
- // FIXME(#3569): Make this conditional on the trait's bounds.
2068
- TC_NONCOPY_TRAIT + TC_OWNED_POINTER
2069
- }
2070
-
2071
- ty_trait( _, _, BoxTraitStore , mutbl, _bounds) => {
2072
- match mutbl {
2073
- ast:: m_mutbl => TC_MANAGED + TC_MUTABLE ,
2074
- _ => TC_MANAGED
2075
- }
2076
- }
2077
-
2078
- ty_trait( _, _, RegionTraitStore ( r) , mutbl, _bounds) => {
2079
- borrowed_contents ( r, mutbl)
2066
+ ty_trait( _, _, store, mutbl, bounds) => {
2067
+ trait_contents ( store, mutbl, bounds)
2080
2068
}
2081
2069
2082
2070
ty_rptr( r, mt) => {
@@ -2278,6 +2266,35 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2278
2266
st + rt + ot
2279
2267
}
2280
2268
2269
+ fn trait_contents ( store : TraitStore , mutbl : ast:: mutability ,
2270
+ bounds : BuiltinBounds ) -> TypeContents {
2271
+ let st = match store {
2272
+ UniqTraitStore => TC_OWNED_POINTER ,
2273
+ BoxTraitStore => TC_MANAGED ,
2274
+ RegionTraitStore ( r) => borrowed_contents ( r, mutbl) ,
2275
+ } ;
2276
+ let mt = match mutbl { ast:: m_mutbl => TC_MUTABLE , _ => TC_NONE } ;
2277
+ // We get additional "special type contents" for each bound that *isn't*
2278
+ // on the trait. So iterate over the inverse of the bounds that are set.
2279
+ // This is like with typarams below, but less "pessimistic" and also
2280
+ // dependent on the trait store.
2281
+ let mut bt = TC_NONE ;
2282
+ for ( AllBuiltinBounds ( ) - bounds) . each |bound| {
2283
+ bt = bt + match bound {
2284
+ BoundCopy if store == UniqTraitStore
2285
+ => TC_NONCOPY_TRAIT ,
2286
+ BoundCopy => TC_NONE , // @Trait/&Trait are copyable either way
2287
+ BoundStatic if bounds. contains_elem ( BoundOwned )
2288
+ => TC_NONE , // Owned bound implies static bound.
2289
+ BoundStatic => TC_BORROWED_POINTER , // Useful for "@Trait:'static"
2290
+ BoundOwned => TC_NON_OWNED ,
2291
+ BoundConst => TC_MUTABLE ,
2292
+ BoundSized => TC_NONE , // don't care if interior is sized
2293
+ } ;
2294
+ }
2295
+ st + mt + bt
2296
+ }
2297
+
2281
2298
fn type_param_def_to_contents ( cx : ctxt ,
2282
2299
type_param_def : & TypeParameterDef ) -> TypeContents
2283
2300
{
0 commit comments