Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crane-utils: migrate from toml_edit to toml #533

Closed
wants to merge 1 commit into from

Conversation

nrabulinski
Copy link

Motivation

Currently toml_edit is used to resolve Cargo.tomls from workspace crates. This was fine but I recently ran into toml-rs/toml#691 which made it impossible for me to compile my project. I thought of trying to fix toml_edit, but then I thought to myself that realistically there's very little gain in trying to preserve the comments and order in Cargo.toml files which the user won't even see unless, as it was in my case, there's a bug and cargo fails while reading it.

It turned out to be very easy to replace toml_edit with toml, while also making the code shorter, and (in my opinion) a bit cleaner.

Checklist

  • added tests to verify new behavior
  • added an example template or updated an existing one
  • updated docs/API.md (or general documentation) with changes
  • updated CHANGELOG.md

@dpc
Copy link
Contributor

dpc commented Feb 26, 2024

There unfortunately seem to be packages do do use comments for stuff #394

@nrabulinski
Copy link
Author

Oh, i did not see that, thanks for pointing that out @dpc. Although IMO there's something wrong with document-features if it's supposed to only affect documentation and yet it causes the compilation to fail when there's a missing comment in Cargo.toml

@ipetkov
Copy link
Owner

ipetkov commented Mar 2, 2024

Thanks for the PR @nrabulinski! Like @dpc mentioned we switched from toml to toml_edit to accommodate things like document-features. It's pretty unfortunate to be stuck waiting on a fix for an upstream bug, but if I had to pick one use case, I'd rather support document-features (it's hopefully "easier" to tweak/patch a Cargo.toml to move/remove unnecessary comments IMO)

I'm thinking another solution would be to expose a more-first-class way of customizing fetching git checkouts (namely adding the ability to insert custom patch hooks for example). Then affected projects can more easily tweak downstream Cargo.tomls without having to switch to their own patched branch

@ipetkov
Copy link
Owner

ipetkov commented Apr 21, 2024

Thanks again for the PR @nrabulinski ! It looks like #583 has a workaround for this by ignoring (stripping) all comments when doing workspace inheritance until toml-rs/toml#691 is fixed. Please take a look and see if that resolves your issue!

In the mean time, I'm going to close this PR in favor of toml-rs/toml#691 since we don't want to regress on supporting comments on feature definitions

@ipetkov ipetkov closed this Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants