|
| 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