Replace toml dependency with toml_edit to preserve comments#407
Merged
Conversation
ipetkov
reviewed
Oct 1, 2023
ipetkov
left a comment
Owner
There was a problem hiding this comment.
Thanks for taking this on! Direction looks good, just have a few minor questions
ipetkov
approved these changes
Oct 1, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
tomlcrate dependency incrane-resolve-workspace-inheritance.rsin 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
tomlcrate 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-featuresused by some embedded libraries, such asembassy-stmf32)Solution
This PR adapts the existing
crane-resolve-workspace-inheritance.rsscript to usetoml_editinstead of thetomlcrate, to preserve comments.Remarks
trait TableLikeExt) is needed to merge any combination of tables.tomlcrate as a dev-dependency, to only check the TOML is equal and avoid string equality; then thefmtmodule 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