Too strict orphan rules E0117
PC-Killer:
Is it possible to correct the behavior?
it is not possible to correct the behavior because the behavior is correct.
PC-Killer:
Here we implement
From<Option<Vec<T>>forOption<MyVec<T>>, and the compiler reports that we voilate the orphan rule. However,MyVecis defined in the scope, so there's no chance that a more specialized overload will be defined in any other modules.
i'm really not sure what you mean by "more specialized". what should stop downstream crates from mplementing impl<T> From<Option<Vec<LocalTy<T>>>> for Option<MyVec<LocalTy<T>>> ?
PC-Killer:
However the compiler just reports that
Option<MyVec<i32>>is foreign, which is a little stupid.
its really not ; Option<MyVec<i32>> is local to the crate that defined Option, the same way MyVec<i32> is local to your crate, and not core, that defined i32.
PC-Killer:
This proves that similar case does make sense, while still being rejected by the compiler.
i am very confused as to what this is supposed to prove ?
this is the current orphan rule
Given
impl<P1..=Pn> Trait<T1..=Tn> for T0, animplis valid only if at least one of the following is true:
Traitis a local trait- All of
- At least one of the types
T0..=Tnmust be a local type. LetTibe the first such type.- No uncovered type parameters
P1..=Pnmay appear inT0..Ti(excludingTi)
if you think you can make a better one that is sound, feel free to do so, but very smart people have worked a long time on making it as relaxed as possible
Discussion in the ATmosphere