Tweak features for regex-syntax#665
Merged
BurntSushi merged 1 commit intorust-lang:masterfrom Apr 17, 2020
Merged
Conversation
This commit tweaks the features enabled for the `regex-syntax` crate from the `regex` crate itself. This isn't intended to actually have any functional change, but should help feature unification for Cargo in some projects. One project I work on exhibits an issue where executing `cargo build` followed by `cargo test` will rebuild `regex-syntax` and all of its transitive dependencies. The cause for this issue is that the tests are using the `proptest` crate. The `proptest` crate depends on `regex-syntax` with normal features (e.g. the defaults). All other crates depend on `regex` with normal default features too. The problem happens where when *only* the `regex` crate depends on `regex-syntax` then the `default` and `unicode` features of `regex-syntax` are disabled. This is because the `regex` crate disables default features and `regex`'s `unicode` feature delegates to all the individual features of `regex-syntax`. When the `regex-syntax` crate is depended on directly by `proptest` it then enables the `default` and `unicode` features of `regex-syntax`. Functionally these two builds of `regex-syntax` are exactly the same since `default` is simply a proxy for `unicode` and `unicode` is simply an umbrella including other features. This PR updates the features enabled on `regex-syntax` by the `regex` crate in two ways: * The `default` feature for `regex` enables `regex-syntax/default`. * The `unicode` feature for `regex` enables the `regex-syntax/unicode` feature. This makes is so that if another crate in your crate graph depends on `regex-syntax` then it'll have, by default, the same set of features enabled than if you also depend on `regex`.
Member
|
@alexcrichton Wow, thank you for the detailed explanation and tracking this down! Definitely agree with this change, and this is probably how I should have set it up in the first place. :-) |
Member
|
This PR is on crates.io in |
Member
Author
|
Thanks so much! And no worries, it took me awhile to track this down b/c I've never had to do this to any other crates before either. A good tip for myself for the future though :) |
bors bot
added a commit
to rust-lang/rust-analyzer
that referenced
this pull request
Apr 19, 2020
4045: Update regex r=kjeremy a=kjeremy Changelog says it reduces unnecessary recompilation of transitive dependencies in some cases. rust-lang/regex#665 Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
This was referenced Oct 13, 2025
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.
This commit tweaks the features enabled for the
regex-syntaxcratefrom the
regexcrate itself. This isn't intended to actually have anyfunctional change, but should help feature unification for Cargo in some
projects.
One project I work on exhibits an issue where executing
cargo buildfollowed by
cargo testwill rebuildregex-syntaxand all of itstransitive dependencies. The cause for this issue is that the tests are
using the
proptestcrate. Theproptestcrate depends onregex-syntaxwith normal features (e.g. the defaults). All othercrates depend on
regexwith normal default features too.The problem happens where when only the
regexcrate depends onregex-syntaxthen thedefaultandunicodefeatures ofregex-syntaxare disabled. This is because theregexcrate disablesdefault features and
regex'sunicodefeature delegates to all theindividual features of
regex-syntax. When theregex-syntaxcrate isdepended on directly by
proptestit then enables thedefaultandunicodefeatures ofregex-syntax.Functionally these two builds of
regex-syntaxare exactly the samesince
defaultis simply a proxy forunicodeandunicodeis simplyan umbrella including other features.
This PR updates the features enabled on
regex-syntaxby theregexcrate in two ways:
defaultfeature forregexenablesregex-syntax/default.unicodefeature forregexenables theregex-syntax/unicodefeature.
This makes is so that if another crate in your crate graph depends on
regex-syntaxthen it'll have, by default, the same set of featuresenabled than if you also depend on
regex.