Commit d7d48e4
committed
Auto merge of #13402 - epage:add, r=weihanglo
fix: Don't duplicate comments when editing TOML
### What does this PR try to resolve?
`toml_edit` <0.22 has a bug that will cause
```toml
[lints]
rust.unsafe_op_in_unsafe_fn = "deny"
rust.explicit_outlives_requirements = "warn"
# rust.unused_crate_dependencies = "warn"
clippy.cast_lossless = "warn"
clippy.doc_markdown = "warn"
clippy.exhaustive_enums = "warn"
```
to be written out as
```toml
[lints]
rust.unsafe_op_in_unsafe_fn = "deny"
rust.explicit_outlives_requirements = "warn"
# rust.unused_crate_dependencies = "warn"
clippy.cast_lossless = "warn"
# rust.unused_crate_dependencies = "warn"
clippy.doc_markdown = "warn"
# rust.unused_crate_dependencies = "warn"
clippy.exhaustive_enums = "warn"
```
when it is parsed and then saved.
See toml-rs/toml#673
This affects any format-preserving edits we do, including:
- `cargo add`
- `cargo remove`
- `cargo init` / `cargo new` editing the workspace
### How should we test and review this PR?
I didn't add any tests as this is covered by `toml_edit`s tests (we already don't cover a fraction of the edit preserving tests it has)
### Additional information3 files changed
+19
-12
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
| 99 | + | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1349 | 1349 | | |
1350 | 1350 | | |
1351 | 1351 | | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
1352 | 1355 | | |
1353 | | - | |
1354 | | - | |
1355 | | - | |
1356 | | - | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
1357 | 1360 | | |
1358 | 1361 | | |
1359 | 1362 | | |
| |||
1367 | 1370 | | |
1368 | 1371 | | |
1369 | 1372 | | |
1370 | | - | |
| 1373 | + | |
1371 | 1374 | | |
1372 | 1375 | | |
1373 | 1376 | | |
| |||
1384 | 1387 | | |
1385 | 1388 | | |
1386 | 1389 | | |
1387 | | - | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
1388 | 1395 | | |
1389 | 1396 | | |
1390 | 1397 | | |
| |||
0 commit comments