-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
experiment with relaxing the orphan rule #136979
Copy link
Copy link
Open
Labels
A-coherenceArea: CoherenceArea: CoherenceA-rust-for-linuxRelevant for the Rust-for-Linux projectRelevant for the Rust-for-Linux projectC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.I-types-nominatedNominated for discussion during a types team meeting.Nominated for discussion during a types team meeting.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-coherenceArea: CoherenceArea: CoherenceA-rust-for-linuxRelevant for the Rust-for-Linux projectRelevant for the Rust-for-Linux projectC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.Items that are on lang's radar and will need eventual work or consideration.I-types-nominatedNominated for discussion during a types team meeting.Nominated for discussion during a types team meeting.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
In Rust-for-Linux, we wish to split our single
kernelcrate into many smaller crates. There are various reasons for this:rust/directory and into their respective subsystems. Then every subsystem should have their own crate(s).While I was splitting off the
pin-initcrate from thekernelcrate in order to keep it in sync with the user-space version, I ran into a problem with the orphan rule. We also had previously anticipated that issues with the orphan rule would pop up if we were to split ourkernelcrate. The issue that I am facing currently is not that bad, as I can solve it with an additional trait. But in the long run, it won't be feasible to always create a workaround for orphan rule conflicts.Note that in the
kernelcrate, we don't need to be protected by the orphan rule, as all 1 dependents (and dependencies exceptcore) of thekernelcrate are under our control directly in-tree. So we would like to have some way to relax the orphan rule for our kernel crates.Here is the error that I am currently running into.
I have this trait in
pin-init(or thekernelcrate before splitting):And an impl in the
kernelcrate for our ownBoxtype:The error that I get is expected, as neither
ZeroablenorOption<T>are declared by thekernelcrate:In the latest RfL sync meeting, I brought this up and @ojeda had a good way of highlighting the problem: it's a chicken-and-egg situation, until we can relax the orphan rule, we're not able to split our crate due to these errors. And in order to know how the orphan rule should be relaxed, we have to split our crate. For this reason, it was suggested in the latest RfL sync meeting to use the following approach: introduce a nightly flag that disables the orphan rule wholesale (edit: for binary crates) and add a lint that warns on the orphan rule being violated. This way, we can split the kernel crate and see what types of orphan rule violations we would like to use without actually stabilizing anything. Miguel also added that you do not even need to ship it into nightly, you can just give us a modified compiler repository and we can test locally with that.
So essentially, this issue is for getting the ball rolling and having some nightly-only/custom-compiler-only flag to disable the orphan rule and see what types of violations we would like to have relaxed. Figuring out a stabilizable solution should come later, when we have an overview over all of the different kinds of relaxations we would like to have.
There also has been a zulip discussion about this topic.
cc @rust-lang/lang
Footnotes
while there are out-of-tree modules, they are always built for a pinned kernel version. When updating, they face the same issue on the C side, so it's OK to break them. ↩