1
- # Review policies
1
+ Review Policy
2
+ =============
3
+
4
+ It is the purpose of code reviews to
5
+
6
+ - ** reduce** the risk of introducing ** bugs** and usability and performance ** regressions** ,
7
+ - keep our code ** maintainable** , ** readable** , and ** documented** , and
8
+ - ensure that changes are made with the big picture and ** appropriate context in mind** .
9
+
10
+ Reviewing accomplishes this by bringing in another set of eyes
11
+ to look at a proposed change from a different perspective,
12
+ which increases the chance of catching mistakes early and
13
+ uncovering potential blind spots in the reasoning behind the change.
14
+
15
+
16
+ ## Basic Reviewing Requirements
17
+
18
+ There are a number of requirements that need to be met in order for reviewing to be effective:
19
+
20
+ - Reviewers must have a sufficient ** understanding of the code** under review.
21
+ > This is important to help spot non-obvious, unintentional side effects of a given change.
22
+ - Pull requests must provide (1) a concise high-level ** description of the change** and (2) the ** rationale** behind it.
23
+ For the rational to be even more useful, authors are encouraged to list potential ** points of contention** .
24
+ > Reviewing code is difficult and reviewers only have a limited amount of time to do it.
25
+ > Jump-starting the review process by not making the reviewer puzzle together the intention and context
26
+ > of a pull request will not only speed things up but also improve the quality of the review.
27
+ - Reviewers must have a good idea on whether they are the ** right person to approve** the change.
28
+ > Knowledge of the code under review is an obvious but not the only criterium for answering this question.
29
+ > The reviewer also needs to decide if they can make the decision alone or if the PR needs to go through
30
+ > the [ major change process] [ mcp ] , if they can perform the review in a timely fashion,
31
+ > and if they are impartial enough to provide a sufficiently unbiased perspective.
32
+
33
+
34
+
35
+ ## Reviewing Checklist
36
+
37
+ The following list of questions (to be posted as part highfive bot's automatic PR response)
38
+ will help reviewers and PR authors alike to bring PRs into good shape and meet the above criteria:
39
+
40
+ > #### Checklist for PR authors and reviewers
41
+ > * Does the PR message have
42
+ > * a concise ** high-level description** of the changes? (* what* is being changed)
43
+ > * a clear ** rationale** for doing them? (* why* is it being changed)
44
+ > * a list of potential ** points of contention** ?
45
+ > * ** links to relevant issues** , RFCs, MCPs, etc?
46
+ > * Does the PR need a ** regression test** ?
47
+ > * Does the change need to be covered by a ** [ major change proposal] [ mcp ] ** ? Is it already covered?
48
+ > * Would someone trying to understand the PR in a year's time be able to quickly ** reconstruct what's going on** ?
49
+ > * Is the new code ** properly documented** ? Is existing documentation still up-to-date?
50
+ > * Does the PR introduce a ** regression** of any of the following:
51
+ > * error message quality
52
+ > * maintainability (e.g. complex code, no documentation, unsafe)
53
+ > * any specific target platforms
54
+ > * downstream tooling (e.g. linkers, debuggers)
55
+ > * compile times
56
+ > * memory usage
57
+ >
58
+ > #### Checklist for reviewers
59
+ > * Am I the ** right person to review** this PR:
60
+ > * Do I understand the code well enough?
61
+ > * Would I be able to spot non-obvious side effects?
62
+ > * Would I be able to fix a bug introduced by this PR?
63
+ > * Can I do the review in a timely fashion?
64
+ > * Do I feel pressure to quickly approve the PR for some reason?
65
+ > * Am I impartial enough?
66
+ > * Before merging:
67
+ > * Is the ** PR message still accurate** ?
68
+ > * Is the ** commit history clean** enough?
69
+
70
+
71
+
72
+ ## Guidance for dealing with common situations
73
+
74
+ In most cases common sense is enough for deciding how to apply this policy.
75
+ However, sometimes there are gray areas where it is not immediately clear how to proceed.
76
+ This section lists a few common cases together with guidance on how to deal with them.
77
+
78
+ * ### I don't think I am a good fit for reviewing - what now?
79
+ It is completely normal that you get assigned a PR (via highfive or otherwise) but don't feel comfortable reviewing it.
80
+ Here is what you can do, depending on the concrete case:
81
+
82
+ - If the change seems really big or contentious, consider asking for an MCP (see below).
83
+ - If you know just the right person for the review, assign them via ` r? @<github-name> ` .
84
+ It's polite to leave a comment asking them if they can take over --
85
+ but you don't have to make sure beforehand that they can actually do it.
86
+ - If you don't know the code well or already have too much on your plate,
87
+ ask highfive to roll the dice again via ` r? @rust-lang/compiler-contributors ` .
88
+
89
+ You can also always ask specific compiler team members for help finding a reviewer.
90
+
91
+ * ### It is unclear if something constitutes a major change
92
+ Deciding if something is a "major change" requiring an [ MCP] [ mcp ] is not always straightforward.
93
+ The official guidelines are [ here] [ whats-a-major-change ] .
94
+ When in doubt, err on side of treating something as a major change.
95
+ You can also nominate the PR for discussion in the compiler team's triage meeting by tagging it ` I-nominated ` .
96
+ If you nominate a PR please make sure to state a concrete question for the compiler team to discuss.
97
+
98
+ * ### Intransparent discussion and rationale
99
+ Sometimes there are PRs that seem to be the result of some prior discussion, with no description or rationale.
100
+ They usually have a title like "Change X" and the only content of the PR message is "r? @xyz ".
101
+ Even though the change might make sense and may even have been suggested by a compiler team member this is not good form.
102
+ The PR message should give a self-contained description of what is being changed,
103
+ why it is being changed and anything else that might be of interest.
104
+ Try to put yourself in the shoes of someone who, a few years down the road,
105
+ needs to fix a bug related to the code touched by the PR and needs to reconstruct the rationale for the way things are.
106
+
107
+ * ### Reviewer and PR author report to the same entity / work for the same employer
108
+ There is no rule that prevents two employees of the same company from reviewing each other's PRs.
109
+ The concerns in such a case are no different than for any other two reviewers.
110
+ We expect the mechanisms and principles we articulated above to be respected by ALL reviewers, whatever their employer.
111
+ Does the PR concisely describe the changes that are being made?
112
+ Does it give a clear, transparent rationale for why the changes make sense
113
+ so that contributors down the line can follow the reasoning and reconstruct what's going on?
114
+ Have points of contention been discussed and cleared up?
115
+ Then you are in the clear.
116
+
117
+ If you are in doubt if something is contentious, give a heads up to ` @rust-lang/compiler-contributors ` and ask for another opinion.
118
+ If the proposed change is large and/or potentially has a big impact, create a [ major change proposal] [ mcp ] .
119
+
120
+ * ### Reviewing and Mentoring
121
+ In the course of mentoring someone through a PR it often happens that the reviewer has ended up effectively co-writing the changes.
122
+ This can be a tricky case because the reviewer is effectively approving their own changes.
123
+ There are a number of considerations to take into account when deciding how to proceed:
124
+
125
+ - If the general direction of the changes has already been approved as part of an MCP and the concrete advice given
126
+ during mentoring was only concerned with resolving minor technical issues, then no further review is required.
127
+ - Similarly, if any contentious decisions have visibly been discussed and resolved on the PR with other
128
+ compiler team contributors and the rest of the changes don't deviate from the general direction that has been
129
+ agreed upon then no further review is required either.
130
+ - If the PR was opened as a response to a concrete suggestion by the reviewer (and the changes are not entirely trivial)
131
+ then it is advisable that the final review is done by someone else.
132
+ However, the initial reviewer/mentor is encouraged to help bring the PR into good shape before handing it off.
133
+
134
+ In general, it is advisable to ask for a second opinion by someone knowledgable in the field in such cases,
135
+ just to increase the chance of uncovering oversights and blindspots a mentor might have.
136
+
137
+ * ### Nobody understands the code that's being changed
138
+ Sometimes there is a bug in some code that nobody understands anymore.
139
+ The original authors are unavailable and it is hard to gauge the implications of a proposed fix.
140
+ In such a case it is a good idea for reviewers to nominate the PR (by tagging it with ` I-nominated ` )
141
+ in order to get it in front of more eyes during the compiler team's triage meeting.
142
+ In such cases it is also especially valuable to gather and document as much information as possible on the issue,
143
+ such as a description of the problem being fixed, points of unclarity, potential risks,
144
+ alternatives that have been considered, et cetera.
145
+ Reviewers should ask PR authors to add this kind of information as comments in the code
146
+ and/or to the PR message (which will become part of the git commit history).
147
+
148
+
149
+ [ mcp ] : https://forge.rust-lang.org/compiler/mcp.html
150
+ [ whats-a-major-change ] : https://forge.rust-lang.org/compiler/mcp.html#what-constitutes-a-major-change
151
+
152
+
153
+ ## Technical Aspects of Reviewing
2
154
3
155
Every PR that lands in the compiler and its associated crates must be
4
156
reviewed by at least one person who is knowledgeable with the code in
@@ -11,7 +163,7 @@ will automatically assign someone.
11
163
It is common to leave a ` r? @username ` comment at some later point to
12
164
request review from someone else. This will also reassign the PR.
13
165
14
- ## bors
166
+ ### bors
15
167
16
168
We never merge PRs directly. Instead, we use bors. A qualified
17
169
reviewer with bors privileges (e.g., a [ compiler
@@ -27,7 +179,7 @@ delegate+` or `@bors delegate=username`. This will allow the PR author
27
179
to approve the PR by issuing ` @bors ` commands like the ones above
28
180
(but this privilege is limited to the single PR).
29
181
30
- ## Reverts
182
+ ### Reverts
31
183
32
184
If a merged PR is found to have caused a meaningful unanticipated regression,
33
185
the best policy is to revert it quickly and re-land it later once a fix and
@@ -49,7 +201,7 @@ with one or more compiler team members pointing to this PR, or it's simply
49
201
obvious to everyone involved). Only revert with lower certainty if the issue is
50
202
particularly critical or urgent to fix.
51
203
52
- ### Creating reverts
204
+ #### Creating reverts
53
205
54
206
The easiest method for creating a revert is to use the "Revert" button on
55
207
Github. This appears next to the "bors merged commit abcd" message on a pull
@@ -93,7 +245,7 @@ Generally speaking, reverts should have elevated priority and match the `rollup`
93
245
status of the PR they are reverting. If a non-rollup PR is shown to have no
94
246
impact on performance, it can be marked ` rollup=always ` .
95
247
96
- ### Forward fixes
248
+ #### Forward fixes
97
249
98
250
Often it is tempting to address a regression by posting a follow-up PR that,
99
251
rather than reverting the regressing PR, instead augments the original in
@@ -114,7 +266,7 @@ most cases it is much easier to land the PR a second time once a fix can be
114
266
confirmed. Allowing a revert to land takes pressure off of you and your
115
267
reviewers to act quickly and gives you time to address the issue fully.
116
268
117
- ## Rollups
269
+ ### Rollups
118
270
119
271
All reviewers are strongly encouraged to explicitly mark a PR as to whether or
120
272
not it should be part of a [ rollup] . This is usually done either when approving a
@@ -156,7 +308,7 @@ is substituted with one of the following:
156
308
- ` rollup ` : this is equivalent to ` rollup=always `
157
309
- ` rollup- ` : this is equivalent to ` rollup=maybe `
158
310
159
- ## Priority
311
+ ### Priority
160
312
161
313
Reviewers are encouraged to set one of the rollup statuses listed above
162
314
instead of setting priority. Bors automatically sorts based on the rollup
@@ -186,7 +338,7 @@ The following is some guidance for setting priorities:
186
338
- Absolutely critical fixes
187
339
- Release promotions
188
340
189
- ## Expectations for r+
341
+ ### Expectations for r+
190
342
191
343
bors privileges are binary: the bot doesn't know which code you are
192
344
familiar with and what code you are not. They must therefore be used
0 commit comments