Skip to content

Commit b235441

Browse files
authored
Merge pull request #19 from davidtwco/crates-policy-draft
Add initial draft of crates policy.
2 parents fe70232 + b786e20 commit b235441

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed

procedures/crates.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Third-party and out-of-tree crates
2+
This document describe the guidelines for creating out-of-tree crates for use in the compiler and
3+
using third-party crates within the compiler. These guidelines were originally discussed at the
4+
Rust All Hands 2019 by the compiler team and others; and then at the
5+
[01/03/2019 steering meeting][steering_meeting].
6+
7+
[steering_meeting]: https://github.com/rust-lang/compiler-team/blob/master/minutes/steering-meeting/2019.03.01.md
8+
9+
## Out-of-tree crates
10+
One of the primary goals of this policy is to ensure that there is consistency in how out-of-tree
11+
crates used in the compiler are set up (at least, those maintained by the compiler team and living
12+
in `rust-lang`) and that the experience is uniform across `rust-lang/rust` and these crates.
13+
14+
### When should parts of the compiler be extracted into an out-of-tree crate?
15+
This is left to the discretion of compiler team members but should be discussed with the rest of
16+
the team, either through raising the question at the weekly triage meeting or asynchronously using
17+
an FCP in an issue. If the crate is a product of a working group, there should already be agreement
18+
within the working group that an out-of-tree crate is suitable.
19+
20+
When considering creating an out-of-tree crate, it is worth balancing how general the crate should
21+
be with the increased maintenance burden that this may bring if widely used.
22+
23+
### Where should compiler crates live?
24+
Out-of-tree compiler crates should be hosted in the `rust-lang` organization - this simplifies
25+
integration with external infrastructure tooling and will inherit existing team permissions on
26+
GitHub. It should be made clear in any documentation that the compiler team and any appropriate
27+
working groups are responsible for the crate. It is not recommended to start with a prototype in
28+
another organization or personal repository.
29+
30+
### Can existing out-of-tree crates from personal accounts or other organizations be transferred?
31+
Yes, this is encouraged. In order to do this, discuss this with the team and familiarize yourself
32+
with [the GitHub documentation for repository transfers][repo_transfers] and then arrange to perform
33+
the transfer. Once a transfer is complete, a redirect will exist in the original account or
34+
organization and this will conflict with the names of any new forks of the transferred repository -
35+
an email to GitHub is required to resolve this.
36+
37+
[repo_transfers]: https://help.github.com/en/articles/transferring-a-repository
38+
39+
### Who owns these crates?
40+
It is desired that a compiler team member or working group has loose ownership over a crate so
41+
that there are clear owners who are responsible for making sure that new versions are published and
42+
that pull requests are reviewed.
43+
44+
### What should these crates be named?
45+
Crate naming will be discussed when new out-of-tree crates are proposed to the compiler team.
46+
47+
Crate naming will differ on a case-by-case basis. Crates that are inherently tied to the
48+
compiler would benefit from a name that is prefixed with `rustc_`. This is an indicator of how
49+
stable the crate may be to prospective users. Other crates, which are more general-purpose, will
50+
have names that are disentangled from the compiler.
51+
52+
### Are there any limitations on the review policy for out-of-tree crates?
53+
Generally, the working groups and team members that are primarily free to maintain the crate using
54+
whatever practices are best suited to their group, however, there are some limitations so that there
55+
is some uniformity across the compiler and out-of-tree crates:
56+
57+
- Everyone with r+ on `rust-lang/rust` should be able to review and approve PRs.
58+
- Where possible, only active participants in the crate (or related working group) need be on the
59+
highfive rotation for the crate.
60+
- It is fine to have additional reviewers on the crate who do not otherwise have r+ for Rust as a
61+
whole, if those reviewers are actively involved in the working group or crate maintenance.
62+
- Major pull requests should have multiple reviewers.
63+
64+
### What is required of an out-of-tree crate?
65+
It is required that out-of-tree crates must:
66+
67+
- Be dual-licensed with Apache 2.0 and MIT when maintained by the compiler team (as the compiler
68+
is) unless there is a compelling reason to do otherwise.
69+
- If another license is desired, this must be brought up when proposing the new crate for
70+
compiler team members to agree. Prefer [licenses accepted by tidy][licenses], unless otherwise
71+
required (ports of code from other projects, etc).
72+
- Abide by Rust's code of conduct.
73+
- Specify that the crate is maintained by the Rust compiler team and any appropriate working groups.
74+
- In particular, this should detail the expected level of maintenance and stability for any
75+
prospective users.
76+
- This should also link to the working group details in this repository.
77+
- Be added to the list at the bottom of this page.
78+
- Follow semantic versioning.
79+
- Use `@bors` and `@rust-highfive`.
80+
- Use labels that are compatible with the existing triage process. This will allow nominated issues
81+
in your out-of-tree crate to be discussed during triage meetings.
82+
- eg. `T-compiler`, `I-nominated` (a full list is to be decided)
83+
84+
### Is there a requirement for community infrastructure for an out-of-tree crate?
85+
There is no requirement that community infrastructure (such as Zulip servers/streams) be created for
86+
out-of-tree crates. This may be desirable if an out-of-tree crate gains a large community of
87+
contributors and users, but otherwise, the working group or compiler team streams should be used
88+
initially.
89+
90+
Linkifiers for auto-linking to issues and PRs on the primary Rust Zulip server can be added on
91+
request.
92+
93+
### Are there any recommendations for working with out-of-tree crates?
94+
Recommendations for working with out-of-tree crates will be documented in the rustc-guide, see
95+
[rust-lang/rustc-guide#285][guide_issue] for progress.
96+
97+
[licenses]: https://github.com/rust-lang/rust/blob/master/src/tools/tidy/src/deps.rs#L10-L19
98+
[guide_issue]: https://github.com/rust-lang/rustc-guide/issues/285
99+
100+
---
101+
102+
In summary, the process for establishing an out-of-tree crate is as follows:
103+
104+
1. Where appropriate, discuss and confirm the need within the working group for the out-of-tree
105+
crate.
106+
2. Create a PR modifying this document to include the crate in the list below. Use
107+
[`@rfcbot merge`](https://github.com/anp/rfcbot-rs#usage) to gain agreement from compiler
108+
team members.
109+
3. Create a new repository in the `rust-lang` organization (permissions should be available for all
110+
compiler team members).
111+
4. Add a README describing the intended purpose of the crate, which team and working group are
112+
responsible (link to their page in this repository) and the intended level of maintenance and
113+
stability.
114+
115+
> This crate is developed and maintained by the [Rust compiler team](..) for use within
116+
> `rustc`, in particular, it is the responsibility of the
117+
> [`.template`](../working-groups/.template) working group. This crate [will have regular
118+
> breaking changes and provides no stability guarantees|is intended to remain stable and have
119+
> limited breaking changes].
120+
5. Include the [LICENSE-APACHE][apache] and [LICENSE-MIT][mit] files from `rust-lang/rust`.
121+
6. Include or link the [CODE_OF_CONDUCT][coc] file from `rust-lang/rust`.
122+
7. Consult with the infrastructure team to set up `@bors` and `@rust-highfive` and a process for
123+
publishing under the "The Rust Project Developers" crates.io account.
124+
8. Perform any initial development required before integration with rustc.
125+
9. Publish initial version, following semantic versioning.
126+
10. Add the crate as a dependency to the appropriate in-tree crate and start using.
127+
128+
[apache]: https://github.com/rust-lang/rust/blob/master/LICENSE-APACHE
129+
[coc]: https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md
130+
[mit]: https://github.com/rust-lang/rust/blob/master/LICENSE-MIT
131+
132+
## Third-party crates
133+
It is sometimes desirable to use the functionality of an existing third-party crate in the compiler.
134+
135+
### When can a third-party crate be added as a compiler dependency?
136+
It is desirable that a third-party crate being included in the compiler is well-maintained and that,
137+
where possible, a compiler team member is added as a maintainer. You should consulting with the
138+
rest of the compiler team before making this decision.
139+
140+
### What about third-party dependencies to out-of-tree crates?
141+
The same policies apply to all compiler-team-maintained crates used in the compiler.
142+
143+
## List of out-of-tree crates
144+
This section contains the list of existing out-of-tree, compiler team-maintained crates:
145+
146+
- [`rust-lang-nursery/chalk`](https://github.com/rust-lang-nursery/chalk/)
147+
- [`rust-lang-nursery/polonius`](https://github.com/rust-lang-nursery/polonius/)

0 commit comments

Comments
 (0)