Skip to content

Commit 738e1cb

Browse files
committed
add missing title
1 parent a8a7878 commit 738e1cb

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/conventions.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
# Coding conventions
2+
13
This file offers some tips on the coding conventions for rustc. This
24
chapter covers [formatting](#formatting), [coding for correctness](#cc),
35
[using crates from crates.io](#cio), and some tips on
46
[structuring your PR for easy review](#er).
57

68
<a id="formatting"></a>
79

8-
# Formatting and the tidy script
10+
## Formatting and the tidy script
911

1012
rustc is moving towards the [Rust standard coding style][fmt].
1113

@@ -28,7 +30,7 @@ pass the <!-- date-check: nov 2022 --> `--edition=2021` argument yourself when c
2830

2931
[`rustfmt`]:https://github.com/rust-lang/rustfmt
3032

31-
## Formatting C++ code
33+
### Formatting C++ code
3234

3335
The compiler contains some C++ code for interfacing with parts of LLVM that
3436
don't have a stable C API.
@@ -41,7 +43,7 @@ When modifying that code, use this command to format it:
4143
This uses a pinned version of `clang-format`, to avoid relying on the local
4244
environment.
4345

44-
## Formatting and linting Python code
46+
### Formatting and linting Python code
4547

4648
The Rust repository contains quite a lot of Python code. We try to keep
4749
it both linted and formatted by the [ruff][ruff] tool.
@@ -65,7 +67,7 @@ environment.
6567

6668
<!-- REUSE-IgnoreStart -->
6769
<!-- Prevent REUSE from interpreting the heading as a copyright notice -->
68-
## Copyright notice
70+
### Copyright notice
6971
<!-- REUSE-IgnoreEnd -->
7072

7173
In the past, files began with a copyright and license notice. Please **omit**
@@ -75,7 +77,7 @@ MIT/Apache-2.0).
7577
All of the copyright notices should be gone by now, but if you come across one
7678
in the rust-lang/rust repo, feel free to open a PR to remove it.
7779

78-
## Line length
80+
### Line length
7981

8082
Lines should be at most 100 characters. It's even better if you can
8183
keep things to 80.
@@ -88,18 +90,18 @@ that case, you can add a comment towards the top of the file like so:
8890
// ignore-tidy-linelength
8991
```
9092

91-
## Tabs vs spaces
93+
### Tabs vs spaces
9294

9395
Prefer 4-space indent.
9496

9597
<a id="cc"></a>
9698

97-
# Coding for correctness
99+
## Coding for correctness
98100

99101
Beyond formatting, there are a few other tips that are worth
100102
following.
101103

102-
## Prefer exhaustive matches
104+
### Prefer exhaustive matches
103105

104106
Using `_` in a match is convenient, but it means that when new
105107
variants are added to the enum, they may not get handled correctly.
@@ -109,7 +111,7 @@ other treatment? Unless the answer is "low", then prefer an
109111
exhaustive match. (The same advice applies to `if let` and `while
110112
let`, which are effectively tests for a single variant.)
111113

112-
## Use "TODO" comments for things you don't want to forget
114+
### Use "TODO" comments for things you don't want to forget
113115

114116
As a useful tool to yourself, you can insert a `// TODO` comment
115117
for something that you want to get back to before you land your PR:
@@ -136,13 +138,13 @@ if foo {
136138

137139
<a id="cio"></a>
138140

139-
# Using crates from crates.io
141+
## Using crates from crates.io
140142

141143
See the [crates.io dependencies][crates] section.
142144

143145
<a id="er"></a>
144146

145-
# How to structure your PR
147+
## How to structure your PR
146148

147149
How you prepare the commits in your PR can make a big difference for the
148150
reviewer. Here are some tips.
@@ -172,7 +174,7 @@ require that every intermediate commit successfully builds – we only
172174
expect to be able to bisect at a PR level. However, if you *can* make
173175
individual commits build, that is always helpful.
174176

175-
# Naming conventions
177+
## Naming conventions
176178

177179
Apart from normal Rust style/naming conventions, there are also some specific
178180
to the compiler.

0 commit comments

Comments
 (0)