Skip to content

Commit 434be94

Browse files
committed
Auto merge of #9270 - jonhoo:document-patch-in-config, r=ehuss
Document `-Zpatch-in-config` Tracking issue: #9269
2 parents 695465c + 81116a9 commit 434be94

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/doc/src/reference/unstable.md

+25
Original file line numberDiff line numberDiff line change
@@ -1156,3 +1156,28 @@ absolute path.
11561156
TMPDIR = { value = "/home/tmp", force = true }
11571157
OPENSSL_DIR = { value = "vendor/openssl", relative = true }
11581158
```
1159+
1160+
### patch-in-config
1161+
* Original Pull Request: [#9204](https://github.com/rust-lang/cargo/pull/9204)
1162+
* Tracking Issue: [#9269](https://github.com/rust-lang/cargo/issues/9269)
1163+
1164+
The `-Z patch-in-config` flag enables the use of `[patch]` sections in
1165+
cargo configuration files (`.cargo/config.toml`). The format of such
1166+
`[patch]` sections is identical to the one used in `Cargo.toml`.
1167+
1168+
Since `.cargo/config.toml` files are not usually checked into source
1169+
control, you should prefer patching using `Cargo.toml` where possible to
1170+
ensure that other developers can compile your crate in their own
1171+
environments. Patching through cargo configuration files is generally
1172+
only appropriate when the patch section is automatically generated by an
1173+
external build tool.
1174+
1175+
If a given dependency is patched both in a cargo configuration file and
1176+
a `Cargo.toml` file, the patch in `Cargo.toml` is used. If multiple
1177+
configuration files patch the same dependency, standard cargo
1178+
configuration merging is used, which prefers the value defined closest
1179+
to the current directory, with `$HOME/.cargo/config.toml` taking the
1180+
lowest precedence.
1181+
1182+
Relative `path` dependencies in such a `[patch]` section are resolved
1183+
relative to the configuration file they appear in.

0 commit comments

Comments
 (0)