Switch to 2021 edition and Cargo's v2 resolver #510
Merged
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.
2021 edition is supported since Rust 1.56 (October 2021). Based on #462, syntect's current toolchain support is 1.73+, so there should be no issue with version support.
Cargo uses a different feature resolver by default when the project root uses 2021 edition. https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html. Example behavior difference relevant to syntect:
With 2018 edition,
cargo check
will build serde with "derive" feature turned on, despite not having runcargo check --tests
i.e. the feature is definitely not needed for this build. With 2021 edition,cargo check
will build serde with "derive" feature off, whilecargo check --tests
builds serde with "derive" feature on.We can see the impact this has on syntect by running
cargo tree --format '{p} [{f}]' > 2018
with 2018 edition andcargo tree --format '{p} [{f}]' > 2021
with 2021 edition, followed bydiff 2018 2021
. Here are the packages that this PR immediately affects:I am sending this PR to prepare for a different PR I intend to send, which will make syntect no longer depend on serde's "derive" feature, allowing better pipelining of downstream builds.
Syntect switching to 2021 edition or v2 resolver is not a hard prerequisite for that other PR, because only the project root is relevant to what resolver Cargo chooses to use. A single resolver is used per build, not per crate. So, the downstream projects would get the benefit of pipelining whether or not syntect uses the v2 resolver in its own repo.
However, I am sending this PR first because it enables the next PR to be profiled (
cargo build --timings
) against syntect in isolation. Without this PR, profiling would need to be done against some other repo instead, because profiling in this repo would be misleading as syntect's dev-dependencies would cause features to be turned on which are not necessarily turned on when some other crate depends on syntect.