Skip to content

Commit bb3392e

Browse files
committed
update conventions
1 parent 952f936 commit bb3392e

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [Profiling the compiler](./profiling.md)
2020
- [with the linux perf tool](./profiling/with_perf.md)
2121
- [Coding conventions](./conventions.md)
22+
- [crates.io Dependencies](./crates-io.md)
2223

2324
---
2425

src/conventions.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ rustc is slowly moving towards the [Rust standard coding style][fmt];
1111
at the moment, however, it follows a rather more *chaotic* style. We
1212
do have some mandatory formatting conventions, which are automatically
1313
enforced by a script we affectionately call the "tidy" script. The
14-
tidy script runs automatically when you do `./x.py test` and can be run
14+
tidy script runs automatically when you do `./x.py test` and can be run
1515
in isolation with `./x.py test src/tools/tidy`.
1616

1717
[fmt]: https://github.com/rust-lang-nursery/fmt-rfcs
@@ -133,3 +133,18 @@ require that every intermediate commit successfully builds – we only
133133
expect to be able to bisect at a PR level. However, if you *can* make
134134
individual commits build, that is always helpful.
135135

136+
# Naming conventions
137+
138+
Apart from normal Rust style/naming conventions, there are also some specific
139+
to the compiler.
140+
141+
- `cx` tends to be short for "context" and is often used as a suffix. For
142+
example, `tcx` is a common name for the [Typing Context][tcx].
143+
144+
- [`'tcx` and `'gcx`][tcx] are used as the lifetime names for the Typing
145+
Context.
146+
147+
- Because `crate` is a keyword, if you need a variable to represent something
148+
crate-related, often the spelling is changed to `krate`.
149+
150+
[tcx]: ./ty.md

src/crates-io.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# crates.io Dependencies
2+
3+
The rust compiler supports building with some dependencies from `crates.io`.
4+
For example, `log` and `env_logger` come from `crates.io`.
5+
6+
In general, you should avoid adding dependencies to the compiler for several
7+
reasons:
8+
9+
- The dependency may not be high quality or well-maintained, whereas we want
10+
the compiler to be high-quality.
11+
- The dependency may not be using a compatible license.
12+
- The dependency may have transitive dependencies that have one of the above
13+
problems.
14+
15+
TODO: what is the vetting process?
16+
17+
## Whitelist
18+
19+
The `tidy` tool has a [whitelist] of crates that are allowed. To add a
20+
dependency that is not already in the compiler, you will need to add it to this
21+
whitelist.
22+
23+
[whitelist]: https://github.com/rust-lang/rust/blob/659994627234ce7d95a1a52ad8756ce661059adf/src/tools/tidy/src/deps.rs#L56

0 commit comments

Comments
 (0)