-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicit OIBIT impls hide the default impls #27554
Comments
I've been experimenting with ways to fix this, and, oddly, there's a unit test checking that this doesn't work: https://github.com/rust-lang/rust/blob/master/src/test/compile-fail/typeck-default-trait-impl-precedence.rs The OIBIT RFC seems pretty clear that this is supposed to be accepted, but I know that the rules specified there for negative impls are thought to be too lenient, so maybe this part is also frowned upon? |
As explained in #23072, this was the semantics we implemented, which diverged somewhat from the RFC. It's interesting that this can come about without feature gates (though obvious in retrospect). |
triage: P-medium We discussed this last week in the language subteam meeting. Our conclusion was that there is (potentially) an issue here where the desired semantics are not entirely clear. It is backwards incompatible to fix it but deemed low risk, because the bad scenario is when one is trying to "add to" the default set that obey a particular trait (or remove further from the negative set, I suppose). Some notes from our discussion: The intent of an impl like this is somewhat unclear. Why did one write the impl in the first place? Was the goal to cover a case that the default rules would have excluded? Or was it perhaps to narrow down the default rules to a smaller set of acceptable cases (which kind of "opts out" by "opting in")? The latter is the current semantics; it does seem plausible that a naive read of the code might think that the impl was listing out the cases that are |
Nominating for retriage and updates. Old type system issue. |
Not |
I believe that there is no bug here: the compiler is doing the right thing, essentially. I've been meaning for some time to write-up an amendment to the OIBIT (now: auto trait) RFC to talk about it for some time. My current thoughts (more-or-less) are embedded in this gist, which also covers the connection to negative reasoning. |
Going to close this issue -- this is the desired semantics -- but we do need to write an amendment to the RFC, I think. |
Nothing in this example opts out of
Sync
or contains a type that opts out, so everything should beSync
.I suspect this is the same underlying issue as #23072, but unlike in that case this seems like something that should be allowed.
The text was updated successfully, but these errors were encountered: