@@ -850,6 +850,7 @@ pub enum BuiltinBound {
850
850
BoundFreeze ,
851
851
BoundSized ,
852
852
BoundPod ,
853
+ BoundShare ,
853
854
}
854
855
855
856
pub fn EmptyBuiltinBounds ( ) -> BuiltinBounds {
@@ -862,6 +863,7 @@ pub fn AllBuiltinBounds() -> BuiltinBounds {
862
863
set. add ( BoundSend ) ;
863
864
set. add ( BoundFreeze ) ;
864
865
set. add ( BoundSized ) ;
866
+ set. add ( BoundShare ) ;
865
867
set
866
868
}
867
869
@@ -1872,31 +1874,32 @@ macro_rules! def_type_content_sets(
1872
1874
1873
1875
def_type_content_sets ! (
1874
1876
mod TC {
1875
- None = 0b0000__00000000__0000 ,
1877
+ None = 0b0000_0000__0000_0000__0000 ,
1876
1878
1877
1879
// Things that are interior to the value (first nibble):
1878
- InteriorUnsized = 0b0000__00000000__0001 ,
1879
- // InteriorAll = 0b0000__00000000__1111 ,
1880
+ InteriorUnsized = 0b0000_0000__0000_0000__0001 ,
1881
+ // InteriorAll = 0b0000_0000__0000_0000__1111 ,
1880
1882
1881
1883
// Things that are owned by the value (second and third nibbles):
1882
- OwnsOwned = 0b0000__00000001__0000 ,
1883
- OwnsDtor = 0b0000__00000010__0000 ,
1884
- OwnsManaged /* see [1] below */ = 0b0000__00000100__0000 ,
1885
- OwnsAffine = 0b0000__00001000__0000 ,
1886
- OwnsAll = 0b0000__11111111__0000 ,
1884
+ OwnsOwned = 0b0000_0000__0000_0001__0000 ,
1885
+ OwnsDtor = 0b0000_0000__0000_0010__0000 ,
1886
+ OwnsManaged /* see [1] below */ = 0b0000_0000__0000_0100__0000 ,
1887
+ OwnsAffine = 0b0000_0000__0000_1000__0000 ,
1888
+ OwnsAll = 0b0000_0000__1111_1111__0000 ,
1887
1889
1888
1890
// Things that are reachable by the value in any way (fourth nibble):
1889
- ReachesNonsendAnnot = 0b0001__00000000__0000 ,
1890
- ReachesBorrowed = 0b0010__00000000__0000 ,
1891
- // ReachesManaged /* see [1] below */ = 0b0100__00000000__0000,
1892
- ReachesMutable = 0b1000__00000000__0000 ,
1893
- ReachesAll = 0b1111__00000000__0000 ,
1891
+ ReachesNonsendAnnot = 0b0000_0001__0000_0000__0000 ,
1892
+ ReachesBorrowed = 0b0000_0010__0000_0000__0000 ,
1893
+ // ReachesManaged /* see [1] below */ = 0b0000_0100__0000_0000__0000,
1894
+ ReachesMutable = 0b0000_1000__0000_0000__0000 ,
1895
+ ReachesNoShare = 0b0001_0000__0000_0000__0000 ,
1896
+ ReachesAll = 0b0001_1111__0000_0000__0000 ,
1894
1897
1895
1898
// Things that cause values to *move* rather than *copy*
1896
- Moves = 0b0000__00001011__0000 ,
1899
+ Moves = 0b0000_0000__0000_1011__0000 ,
1897
1900
1898
1901
// Things that mean drop glue is necessary
1899
- NeedsDrop = 0b0000__00000111__0000 ,
1902
+ NeedsDrop = 0b0000_0000__0000_0111__0000 ,
1900
1903
1901
1904
// Things that prevent values from being sent
1902
1905
//
@@ -1905,31 +1908,34 @@ def_type_content_sets!(
1905
1908
// both ReachesManaged and OwnsManaged so that when
1906
1909
// a parameter has a bound T:Send, we are able to deduce
1907
1910
// that it neither reaches nor owns a managed pointer.
1908
- Nonsendable = 0b0111__00000100__0000 ,
1911
+ Nonsendable = 0b0000_0111__0000_0100__0000 ,
1909
1912
1910
1913
// Things that prevent values from being considered freezable
1911
- Nonfreezable = 0b1000__00000000__0000 ,
1914
+ Nonfreezable = 0b0000_1000__0000_0000__0000 ,
1912
1915
1913
1916
// Things that prevent values from being considered 'static
1914
- Nonstatic = 0b0010__00000000__0000 ,
1917
+ Nonstatic = 0b0000_0010__0000_0000__0000 ,
1915
1918
1916
1919
// Things that prevent values from being considered sized
1917
- Nonsized = 0b0000__00000000__0001 ,
1920
+ Nonsized = 0b0000_0000__0000_0000__0001 ,
1921
+
1922
+ // Things that prevent values from being shared
1923
+ Nonsharable = 0b0001_0000__0000_0000__0000 ,
1918
1924
1919
1925
// Things that make values considered not POD (would be same
1920
1926
// as `Moves`, but for the fact that managed data `@` is
1921
1927
// not considered POD)
1922
- Nonpod = 0b0000__00001111__0000 ,
1928
+ Nonpod = 0b0000_0000__0000_1111__0000 ,
1923
1929
1924
1930
// Bits to set when a managed value is encountered
1925
1931
//
1926
1932
// [1] Do not set the bits TC::OwnsManaged or
1927
1933
// TC::ReachesManaged directly, instead reference
1928
1934
// TC::Managed to set them both at once.
1929
- Managed = 0b0100__00000100__0000 ,
1935
+ Managed = 0b0000_0100__0000_0100__0000 ,
1930
1936
1931
1937
// All bits
1932
- All = 0b1111__11111111__1111
1938
+ All = 0b1111_1111__1111_1111__1111
1933
1939
}
1934
1940
)
1935
1941
@@ -1945,6 +1951,7 @@ impl TypeContents {
1945
1951
BoundSend => self . is_sendable ( cx) ,
1946
1952
BoundSized => self . is_sized ( cx) ,
1947
1953
BoundPod => self . is_pod ( cx) ,
1954
+ BoundShare => self . is_sharable ( cx) ,
1948
1955
}
1949
1956
}
1950
1957
@@ -1964,6 +1971,10 @@ impl TypeContents {
1964
1971
!self . intersects ( TC :: Nonsendable )
1965
1972
}
1966
1973
1974
+ pub fn is_sharable ( & self , _: & ctxt ) -> bool {
1975
+ !self . intersects ( TC :: Nonsharable )
1976
+ }
1977
+
1967
1978
pub fn owns_managed ( & self ) -> bool {
1968
1979
self . intersects ( TC :: OwnsManaged )
1969
1980
}
@@ -2284,6 +2295,8 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents {
2284
2295
tc | TC :: Managed
2285
2296
} else if Some ( did) == cx. lang_items . no_pod_bound ( ) {
2286
2297
tc | TC :: OwnsAffine
2298
+ } else if Some ( did) == cx. lang_items . no_share_bound ( ) {
2299
+ tc | TC :: ReachesNoShare
2287
2300
} else {
2288
2301
tc
2289
2302
}
@@ -2362,6 +2375,7 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents {
2362
2375
BoundFreeze => TC :: Nonfreezable ,
2363
2376
BoundSized => TC :: Nonsized ,
2364
2377
BoundPod => TC :: Nonpod ,
2378
+ BoundShare => TC :: Nonsharable ,
2365
2379
} ;
2366
2380
} ) ;
2367
2381
return tc;
0 commit comments