Coherence problem when a generic has a default value from an associated type #61400
Labels
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
I ran into a coherence problem where I think that the compiler is too strict, even though the code should be accepted according to the coherence rules (as far as I can tell).
For the code below, the compiler will report
but passing
O
explicitly (for ItemOrConverted<MyString, String>
) works.The code:
I have a trait with an associated type (
ConvertTo::Output
, in the example below), and an enum which is generic overT: ConvertTo
and generic overO
with a default value forO
based on the associated type fromT
'sConvertTo
, all in one crate.In another crate I have
MyString
, and I would like to implementPartialEq<MyString>
for this enum overMyString
, but without changing the default value forO
. (Thinkimpl PartialEq<MyString> for Cow<MyString>
).Is this really allowed "in theory" by the coherence rules or am I missing something?
(edit: Compiling with
#![feature(re_rebalance_coherence)]
works!)Meta
rustc 1.37.0-nightly (37d001e 2019-05-29)
binary: rustc
commit-hash: 37d001e
commit-date: 2019-05-29
host: x86_64-pc-windows-msvc
release: 1.37.0-nightly
LLVM version: 8.0
The text was updated successfully, but these errors were encountered: