@@ -1856,7 +1856,7 @@ impl TypeContents {
1856
1856
}
1857
1857
1858
1858
pub fn noncopyable ( _cx : ctxt ) -> TypeContents {
1859
- TC_DTOR + TC_BORROWED_MUT + TC_ONCE_CLOSURE + TC_OWNED_CLOSURE +
1859
+ TC_DTOR + TC_BORROWED_MUT + TC_ONCE_CLOSURE + TC_NONCOPY_TRAIT +
1860
1860
TC_EMPTY_ENUM
1861
1861
}
1862
1862
@@ -1905,13 +1905,19 @@ impl TypeContents {
1905
1905
}
1906
1906
1907
1907
pub fn needs_drop ( & self , cx : ctxt ) -> bool {
1908
+ if self . intersects ( TC_NONCOPY_TRAIT ) {
1909
+ // Currently all noncopyable existentials are 2nd-class types
1910
+ // behind owned pointers. With dynamically-sized types, remove
1911
+ // this assertion.
1912
+ assert ! ( self . intersects( TC_OWNED_POINTER ) ) ;
1913
+ }
1908
1914
let tc = TC_MANAGED + TC_DTOR + TypeContents :: owned ( cx) ;
1909
1915
self . intersects ( tc)
1910
1916
}
1911
1917
1912
1918
pub fn owned ( _cx : ctxt ) -> TypeContents {
1913
1919
//! Any kind of owned contents.
1914
- TC_OWNED_CLOSURE + TC_OWNED_POINTER + TC_OWNED_VEC
1920
+ TC_OWNED_POINTER + TC_OWNED_VEC
1915
1921
}
1916
1922
}
1917
1923
@@ -1945,8 +1951,8 @@ static TC_OWNED_POINTER: TypeContents = TypeContents{bits: 0b0000_0000_0010};
1945
1951
/// Contains an owned vector ~[] or owned string ~str
1946
1952
static TC_OWNED_VEC : TypeContents = TypeContents { bits : 0b0000_0000_0100 } ;
1947
1953
1948
- /// Contains a ~fn() or a ~Trait, which is non-copyable .
1949
- static TC_OWNED_CLOSURE : TypeContents = TypeContents { bits : 0b0000_0000_1000 } ;
1954
+ /// Contains a non-copyable ~fn() or a ~Trait (NOT a ~fn:Copy() or ~Trait:Copy) .
1955
+ static TC_NONCOPY_TRAIT : TypeContents = TypeContents { bits : 0b0000_0000_1000 } ;
1950
1956
1951
1957
/// Type with a destructor
1952
1958
static TC_DTOR : TypeContents = TypeContents { bits : 0b0000_0001_0000 } ;
@@ -2061,7 +2067,8 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2061
2067
}
2062
2068
2063
2069
ty_trait( _, _, UniqTraitStore , _, _bounds) => {
2064
- TC_OWNED_CLOSURE
2070
+ // FIXME(#3569): Make this conditional on the trait's bounds.
2071
+ TC_NONCOPY_TRAIT + TC_OWNED_POINTER
2065
2072
}
2066
2073
2067
2074
ty_trait( _, _, BoxTraitStore , mutbl, _bounds) => {
@@ -2184,7 +2191,9 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2184
2191
match sigil {
2185
2192
ast:: BorrowedSigil => TC_BORROWED_POINTER ,
2186
2193
ast:: ManagedSigil => TC_MANAGED ,
2187
- ast:: OwnedSigil => TC_OWNED_CLOSURE
2194
+ // FIXME(#3569): Looks like noncopyability should depend
2195
+ // on the bounds, but I don't think this case ever comes up.
2196
+ ast:: OwnedSigil => TC_NONCOPY_TRAIT + TC_OWNED_POINTER ,
2188
2197
}
2189
2198
}
2190
2199
@@ -2258,7 +2267,11 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2258
2267
let st = match cty. sigil {
2259
2268
ast:: BorrowedSigil => TC_BORROWED_POINTER ,
2260
2269
ast:: ManagedSigil => TC_MANAGED ,
2261
- ast:: OwnedSigil => TC_OWNED_CLOSURE
2270
+ ast:: OwnedSigil => if cty. bounds . contains_elem ( BoundCopy ) {
2271
+ TC_OWNED_POINTER
2272
+ } else {
2273
+ TC_OWNED_POINTER + TC_NONCOPY_TRAIT
2274
+ }
2262
2275
} ;
2263
2276
let rt = borrowed_contents ( cty. region , m_imm) ;
2264
2277
let ot = match cty. onceness {
0 commit comments