File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,19 @@ pub struct BoundRef {
245
245
index : usize ,
246
246
}
247
247
248
+ // SAFETY: The pointer inside `BoundRef` is always (eventually) constructed from Arc::as_ptr
249
+ // from the slab of a type-inference context.
250
+ //
251
+ // Arc will prevent the pointer from ever changing, except to be deallocated when the last
252
+ // Arc goes away. But this occurs only when the context itself goes away, which in turn
253
+ // happens only when every type bound referring to the context goes away.
254
+ //
255
+ // If this were untrue, our use of `BoundRef` would lead to dereferences of a dangling
256
+ // pointer, and `Send`/`Sync` would be the least of our concerns!
257
+ unsafe impl Send for BoundRef { }
258
+ // SAFETY: see comment on `Send`
259
+ unsafe impl Sync for BoundRef { }
260
+
248
261
impl BoundRef {
249
262
pub fn assert_matches_context ( & self , ctx : & Context ) {
250
263
assert_eq ! (
You can’t perform that action at this time.
0 commit comments