rustc only inferred the second two steps. The rest was explicitly provided to it; we *told* the compiler "T: Send => Mutex<T>: Sync+Send"
-
-
relevant line: unsafe impl<T: ?Sized + Send> Sync for Mutex<T> { }
2 replies 0 retweets 2 likes -
Replying to @Gankra_ @ManishEarth and
It really does seem like using `PhantomData` would have made more sense than opting out of the autotrait impl
1 reply 1 retweet 1 like -
PhantomData<&mut T> I suppose? Perhaps. I wonder how the variance of that works out. Actually, there's a chance variance is wrong there.
1 reply 1 retweet 1 like -
Yes. The variance shouldn't change since it'll still have the `&Mutex<T>` reference with the same lifetime.
1 reply 0 retweets 0 likes -
No, but.. If the T itself has a lifetime, we need MutexGuard to be semantically equivalent to &mut T, not &T, so that it's invariant.
1 reply 0 retweets 0 likes -
Wouldn't that imply that the current variance is probably broken?
1 reply 0 retweets 0 likes -
Yes. I'm looking into it.
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @sgrif and
Ok, this *does* fail to compile, which indicates that stuff is working correctly https://is.gd/MgwR3C .
1 reply 1 retweet 1 like -
Replying to @ManishEarth @sgrif and
I suppose Mutex is invariant because of the Cell, and that makes MutexGuard invariant bc of the &Mutex.
1 reply 0 retweets 1 like
Either way, saying "is semantically a &mut T" is much clearer (esp to devs less experienced w/ variance) than that statement
-
-
Replying to @sgrif @ManishEarth and
Theoretically this same bug could exist w/ other autotraits outside the standard lib. PhantomData would help guard against that
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Yes, yes, I agree :) I was just concerned we had another soundness hole lurking here :)
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.