Commit a5566ce
authored
feat: support array of any types in Cargo config (#16103)
### What does this PR try to resolve?
This adds the support of array of any types in Cargo config.
The motivation of this is mostly from the proposed `-Zconfig-include`
syntax
(<#7723 (comment)>)
```toml
[[include]]
path = "a.toml"
optional = true
[[include]]
path = "b.toml"
optional = false
```
which before this Cargo only supported array of string.
Some design decisions:
* **Insta-stabilization**: This is insta- stabilizing a extension of
Cargo config. See
<#16103 (comment)>
* **No `CARGO_*` env support added** — Only the `--config` CLI and
file-based configuration start supporting array of any types. `CARGO_*`
config environment still doesn't. The only type you can set through
environment variable are still primitive types. For advanced env usage,
we left it as follow-up to deal with in `-Zadvanced-env`
* **Nothing changed in config merging rule** — Nested complex types in
array won't merge with any other items, as it still respects the current
array merging rule, which appends items.
* `cargo config get` now prints inline array/tables for array of nested
array/tables.
fixes #16111
### How to test and review this PR?
Starting from the fifth commit, those changes are for handling
diagnostic regression, as now `Config::from_toml` accepts any types and
the invalid type error is delayed from the "TOML->ConfigValue"
deserialization to "ConfigValue->Target" Type deserialization. Not sure
if we should split it to a separate PR, but the solution here I admit is
a bit nasty.File tree
9 files changed
+887
-204
lines changed- src/cargo
- ops
- util/context
- tests/testsuite
- cargo_config
9 files changed
+887
-204
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
118 | 133 | | |
119 | 134 | | |
120 | 135 | | |
| |||
129 | 144 | | |
130 | 145 | | |
131 | 146 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
145 | 150 | | |
146 | 151 | | |
147 | 152 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 153 | + | |
157 | 154 | | |
158 | 155 | | |
159 | 156 | | |
| |||
0 commit comments