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

Fix feature semver violations in v4.7.0 #403

Merged

Conversation

Enselic
Copy link
Collaborator

@Enselic Enselic commented Dec 28, 2021

Fixes #402

I ended up removing the plist-load feature because I see no way of keeping it around in a semver compatible and sane way. The refactoring that made the introduction of that feature possible can we kept however, which is nice. So it should be easy to re-introduce it e.g. v5.0.0 at some later point.

I did consider making plist-load opt-out rather than opt-in to remain semver compatible. We could call it no-plist-load, and if enabled, the unneeded code could be excluded from the build. I think that is too unergonomic and counter-intuitive however, so I think it's better to simply remove it for now.

I also noticed that dump-create-rs and dump-create are the same since 2 years, since 2 years ago the default flate2 backend was changed to Rust. See rust-lang/flate2-rs@c479d064e2. So there is no need to make a distinction any longer. This allows us to remain semver compatible with regards to the lazy-loading changes since now parsing can depend on dump-create and dump-load directly. I did not bother adding an entry about that in CHANGELOG.md since there is no semantic change for clients.

I could reproduce the build error in bat locally, and have confirmed that these changes fixes the build error.

I think it would be a good idea to not rush this PR in. Let's let it sit here for at least a few days so we have time to think this through and perhaps test some more. Any help with testing would be greatly appreciated.

(Oh, and I also noticed that I forgot to add a pub to an API, so I fixed this too in this PR.)

Martin Nordholts added 3 commits December 28, 2021 17:29
It was not enough to make the `default` feature depend on it. Putting code
behind a feature is in practice a semver breakage. See
sharkdp/bat#1991 (comment) and trishume#402.

It was added in trishume#345 after doing some refactoring. We can keep the refactoring,
but we choose to remove the feature for now. Another option would be to make the
feature opt-out rather than opt-in and rename it to `no-plist-load` or similar.
That would be too unergonomic and confusing however, so for now we just remove
it. We might add it back for v5.0.0.
When the `-rs` versions of dump creation and loading were introduced in syntect,
`flate2` defaulted to a C implementation and made the Rust backend optional.
Since two years, the Rust backend has been the default backend. See
rust-lang/flate2-rs@c479d064e2. So we can stop using
the `-rs` versions since enabling them makes no difference.

Note that there is no mechanism yet that we can use to mark features as
deprecated. See rust-lang/cargo#7130
@Enselic
Copy link
Collaborator Author

Enselic commented Jan 2, 2022

I can't think of any changes to this PR, and I have verified locally that this fixes the build error in both cargo-expand and bat (with path = "...," in Cargo.toml) after also reproducing the build errors.

So I think we should go ahead and merge this and release v4.7.1. Worst case we have to yank v4.7.1 too and try again in v4.7.2.

A couple of words on the embarrassing mistake of forgetting the pub that this PR fixes. That it could happen at all is because

  • that API is not used in bat (I regularly verify my changes against bat)
  • that API is not used in any integration tests in syntect (there are tests for the method, but they are internal and thus have access to internal API)

The correct long-term fix to the pub mistake would be to move relevant syntect test cases to ./tests/... so that the tests only have access to public API. Then mistakes like these can be detected at compile time. That will be an adventure for another time though...

Copy link
Owner

@trishume trishume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this looks good!

@trishume trishume merged commit a639a88 into trishume:master Jan 2, 2022
@trishume
Copy link
Owner

trishume commented Jan 2, 2022

I released v4.7.1!

@Enselic Enselic deleted the fix-feature-semver-violations-in-v4.7.0 branch January 3, 2022 07:08
@Enselic
Copy link
Collaborator Author

Enselic commented Jan 3, 2022

@trishume We need to yank v4.7.1 too 😢

While the code indeed compiles, it doesn't run, since the dump format has changed due to the lazy-loading changes:

% cargo expand --lib
memory allocation of 7881122326526296064 bytes failed

I am a very perplexed as to why I did not detect this problem when I verified my change. I must have accidentally and out of habit updated bat assets locally when verifying, and in that case everything works. It never occurred to me that we could have a problem with binary incompatibilities of dumps, but it is obvious in retrospect. I am terribly sorry to waste everyone's time again. I feel very bad about it.

Right now I see no other option than having to bump major version. But let's not rush that release either to give some time to let the situation sink in and allow us think this through. Again.

Since it appears necessary to bump major version, I think we should take the opportunity to at least do the following before doing a 5.0.0 release, which should be pretty simple:

@Enselic
Copy link
Collaborator Author

Enselic commented Jan 3, 2022

To be clear: Projects using pure syntect and the assets that come with syntect should be fine. The problem is projects using bat, since bat ships its own versions of integrated syntaxes that now are binary-incompatible with the latest syntect release.

@trishume
Copy link
Owner

trishume commented Jan 6, 2022

Yup seems like a major version bump is necessary, I didn't think about the fact that changing the binary format requires a semver bump either.

I sent you an offer to be a crates.io maintainer, you can feel free to yank releases in the future, and to publish releases on your own if I'm non-responsive for let's say 4 months, although I don't expect that I would be completely outside of extreme scenarios.

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.

Semver violation in v4.7.0 and v4.7.1
2 participants