Consider this a sort of pre-pre RFC discussion -- I'm trying to gather thoughts and ideas before posting a pre-RFC on this one since I know it's a controversial topic.
I'm interested in exploring ideas for ways to bypass the orphan rule in situations where you as an author or as an organization own and maintain all of the crates in question. One pain point I find with the orphan rule is that Rust uses the crate boundary for multiple orthogonal things. Among other things, it's a compilation unit boundary, and also the boundary at which you can control optimization level. Combining these controls along the same axis as the coherence boundary for the orphan rule can make it difficult to separate large projects into different crates for debugging or compilation speed reasons. I'm experiencing this especially in gamedev, where the game is not performant enough in debug to actually run and test a build (this is not unique to Rust, C++ also has this issue), and so you want to be able to selectively control what is and isn't optimized -- you might want to optimize your engine code, but not optimize your gameplay code. Often when I separate these two layers, I end up with code on opposite sides of the orphan rule boundary that I need to work around in unfriendly ways.
The orphan rule is useful and good for building an ecosystem where largely anonymous collaborators need to agree to a coding contract for the sake of coherence to avoid code breakages downstream and ensure compatibility between any two arbitrary crates. However, in in-house orgs where you can maintain your own coding conventions, can resolve compilation errors through explicit collaboration, and have a greatly reduced scope of concern for compatibility between crates, I find that the orphan rule is less useful and more of an obstacle that necessitates some code smells (newtyping, etc.) to bypass. Because of this, I'd like a way to turn it off between two crates that I own and am willing to accept the compatibility burden for. In this case, I'm also fine if that renders those crates ineligible to upload to crates.io.
I'd like to propose the idea of "linked" or "coherent" crates. Imagine, if you will, a field in your Cargo.toml where you can specify another crate (by name) as a linked/coherent crate, where doing so is reciprocal. If crates A and B are linked in this way, they are considered as being part of the same crate for the sake of coherence and orphan rule application. Crate B can implement a trait from A on a struct from A, or on any other type that crate B pulls in from its dependencies, as if it were happening in crate A.
Certainly this can cause the kinds of issues the orphan rule is designed to prevent. I think it would be reasonable for crates.io to reject crate linking, and to have this be purely an in-org construct for splitting large projects. However, if you are willing to accept the burden for fixing these issues within your org (they would present as compiler errors), I think this would enable greater flexibility.
Am I completely off base here? Any thoughts? What sorts of questions would you like to see addressed in an RFC for this proposal?