You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing to propose we stabilize the implementation of RFC 2451, "re-rebalancing coherence" (tracking issue).
Brief Summary
The RFC modifies the coherence rules. It used to be that, when implementing a non-local trait, if Ti was the first "local type", then all type parameters were forbidden before that point. In practice, that meant that this impl was illegal:
structLocal;impl<T>Foreign<Local>forVec<T>{}// ^^^^^ ^// | type parameter// first local type
The RFC lightly generalizes these rules. In particular, type parameters are now allowed before Ti, but only if they are covered, defined in the RFC as:
Covered Type: A type which appears as a parameter to another type. For example, T is uncovered, but the T in Vec<T> is covered. This is only relevant for type parameters.
This means that the impl above is now legal, because the typeT is covered by Vec. Note that an impl like the following would still be illegal:
structLocal;impl<T>Foreign<Local>forT{}// ^^^^^ ^// | type parameter (uncovered)// first local type
It is considered a (semver) breaking change for parent crates to add impls with uncovered type parameters (this was already the case even with the old rules, I believe). Therefore, this generalization of the rules cannot permit a conflict between the parent crate and a child crate. (See RFC for a more detailed argument.)
(NB: I've elided details of #[fundamental] in this summary, see the RFC for full details.)
Changes since the RFC was approved
None
Test cases
This section describes the patterns covered by new tests added for this RFC, or tests that seemed relevant to this RFC, with links to the test files.
Stabilization Proposal
I am writing to propose we stabilize the implementation of RFC 2451, "re-rebalancing coherence" (tracking issue).
Brief Summary
The RFC modifies the coherence rules. It used to be that, when implementing a non-local trait, if Ti was the first "local type", then all type parameters were forbidden before that point. In practice, that meant that this impl was illegal:
The RFC lightly generalizes these rules. In particular, type parameters are now allowed before Ti, but only if they are covered, defined in the RFC as:
This means that the impl above is now legal, because the type
Tis covered byVec. Note that an impl like the following would still be illegal:It is considered a (semver) breaking change for parent crates to add impls with uncovered type parameters (this was already the case even with the old rules, I believe). Therefore, this generalization of the rules cannot permit a conflict between the parent crate and a child crate. (See RFC for a more detailed argument.)
(NB: I've elided details of
#[fundamental]in this summary, see the RFC for full details.)Changes since the RFC was approved
None
Test cases
This section describes the patterns covered by new tests added for this RFC, or tests that seemed relevant to this RFC, with links to the test files.
impl<T> Foreign<Local> for Foreign<T, Foreign>-- re-rebalance-coherence.rs, re-rebalance-coherence-rpass.rs (these appear to be duplicate tests)impl<T> Foreign for Foreign<T, Local<T>>-- coherence-cow.rs, coherence-cow.rsimpl<T,U> Foreign for Foreign<T, Local<U>>-- coherence-cow.rs, coherence-pair-covered-uncovered.rsimpl<T> Foreign<Local> for T-- coherence-bigint-param.rsimpl Foreign for Local<T>-- coherence-covered-type-parameter.rs, coherence-iterator-vec.rsimpl<T> Foreign<T> for Foreign-- coherence-all-remote.rsimpl Foreign<Local> for Foreign-- coherence-bigint-int.rs, coherence-bigint-vecint.rsimpl<T> Foreign for T-- coherence-cross-crate-conflict.rs, coherence-lone-type-parameter.rsimpl Foreign for Foreign<Local>-- coherence-vec-local.rsimpl<T> Foreign<Foreign<T>, Local> for Foreign<T>-- in add new tests for re_rebalance_coherence #64414impl<T> Foreign<Local> for Fundamental<T>-- in add new tests for re_rebalance_coherence #64414Missing items
re_rebalance_coherencedoesn't properly account for fundamental types #64412