Replace toml
dependency with toml_edit
to preserve comments
#407
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
As discussed in #394, crane currently uses the
toml
crate dependency incrane-resolve-workspace-inheritance.rs
in order to merge the workspace root Cargo.toml with the current crate's Cargo.toml. This script is run on all git dependencies of the built crate.One unfortunate side effect of using the
toml
crate is that all comments are removed from Cargo.toml. This is an issue if proc macros or build scripts are expecting to read non-TOML metadata from Cargo.toml (e.g.document-features
used by some embedded libraries, such asembassy-stmf32
)Solution
This PR adapts the existing
crane-resolve-workspace-inheritance.rs
script to usetoml_edit
instead of thetoml
crate, to preserve comments.Remarks
trait TableLikeExt
) is needed to merge any combination of tables.toml
crate as a dev-dependency, to only check the TOML is equal and avoid string equality; then thefmt
module could be removed.I tested this on my minimal example from #394, and it appears to work correctly. (reference danjl1100/example_uses_dep_using_document_features@7cc5174)
Checklist
docs/API.md
(or general documentation) with changesCHANGELOG.md