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

Tweak features for regex-syntax #665

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

alexcrichton
Copy link
Member

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.

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`.
@BurntSushi BurntSushi merged commit b490e0b into rust-lang:master Apr 17, 2020
@BurntSushi
Copy link
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. :-)

@BurntSushi
Copy link
Member

This PR is on crates.io in regex 1.3.7.

@alexcrichton alexcrichton deleted the more-features branch April 18, 2020 00:22
@alexcrichton
Copy link
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 <[email protected]>
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.

2 participants