Skip to content

Commit 369b3ff

Browse files
committed
docs(contrib): Note areas of consideration for RFCs
1 parent e725a73 commit 369b3ff

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

src/doc/contrib/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [Process](./process/index.md)
77
- [Working on Cargo](./process/working-on-cargo.md)
88
- [Release process](./process/release.md)
9+
- [Writing an RFC](./process/rfc.md)
910
- [Unstable features](./process/unstable.md)
1011
- [Security issues](./process/security.md)
1112
- [Design Principles](./design.md)

src/doc/contrib/src/process/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@ on how this works.
114114
[issue-feature-request]: https://github.com/rust-lang/cargo/labels/C-feature-request
115115
[Feature accepted]: https://github.com/rust-lang/cargo/labels/Feature%20accepted
116116
[design principles chapter]: ../design.md
117-
[RFC process]: https://github.com/rust-lang/rfcs/
117+
[RFC process]: ./rfc.md
118118
[irlo]: https://internals.rust-lang.org/
119119
[subcommands]: https://doc.rust-lang.org/cargo/reference/external-tools.html#custom-subcommands

src/doc/contrib/src/process/rfc.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Writing an RFC
2+
3+
Generally, an RFC goes through:
4+
1. Pre-RFC discussions on the [internals forum][irlo]
5+
2. [RFC]
6+
3. [Development and stabilization][unstable]
7+
8+
Please keep in mind our [design principles](../design.md).
9+
10+
For more concrete areas of consideration:
11+
12+
## `.cargo/config.toml` and `Cargo.toml`
13+
14+
`.cargo/config.toml` is for environment or transient configuration,
15+
being dependent on what directory you are running from and settable on the command-line,
16+
independent of other flags like `--manifest-path` or `--package`.
17+
18+
On the other hand `Cargo.toml` is for static, high-level project configuration.
19+
20+
For example,
21+
- [RFC 3537] chose
22+
configuration for the MSRV-aware resolver because users would likely need
23+
to change this setting, like in CI to verify the opposite case of
24+
what they run by default.
25+
- The Cargo team rejected a [`[cfg]` table][cfg table] to represent `rustc`
26+
`--cfg` flags as it was a direct port of low-level rustc behavior that didn't
27+
mesh with the other high level abstractions of manifests.
28+
- For stabilization, this was worked around through a build script directive and a `[lints]` field configuration.
29+
- [#12738][cargo#12738] for exploring how existing config might be representable in `Cargo.toml`.
30+
31+
32+
[irlo]: https://internals.rust-lang.org/
33+
[RFC]: https://github.com/rust-lang/rfcs/
34+
[unstable]: unstable.md
35+
[RFC 3537]: https://rust-lang.github.io/rfcs/3537-msrv-resolver.html
36+
[cfg table]: https://github.com/rust-lang/cargo/pull/11631#issuecomment-1487424886
37+
[cargo#12738]: https://github.com/rust-lang/cargo/issues/12738
38+
39+
## `Cargo.toml`
40+
41+
When adding a table to a manifest,
42+
- Should it be inheritable?
43+
- Ensure the package table and the inheritable table under `workspace` align
44+
- Care is needed to ensure a `workspace = true` field doesn't conflict with other entries
45+
- e.g. [RFC 3389] had to explicitly exclude ever supporing a `workspace` linter
46+
47+
When adding a field,
48+
- Is it inheritable?
49+
- Consider whether sharing of the field would be driven by requirements or is a manifestion of the current implementation.
50+
For example, in most cases, dependency sources (e.g. `version` field) should be aligned across a workspace
51+
However, frequently dependency `features` will vary across a workspace.
52+
- When inheriting, can specify it in your package?
53+
- How does specifying a field in both `workspace` and a package interact?
54+
- e.g. dependency sources cannot be overridden
55+
- e.g. dependency `features` get merged
56+
- e.g. depedency `default-features` has been hard to get right ([#12162][cargo#12162])
57+
58+
When working extending `dependencies` tables:
59+
- How does this affect `cargo add` or `cargo remove`?
60+
- How does this affect `[patches]` which are just modified dependencies?
61+
62+
[RFC 3389]: https://rust-lang.github.io/rfcs/3389-manifest-lint.html
63+
[cargo#12162]: https://github.com/rust-lang/cargo/issues/12162
64+

0 commit comments

Comments
 (0)