-
Notifications
You must be signed in to change notification settings - Fork 80
Use new string_cache_codegen crate for static atoms #136
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
Conversation
|
Why a separate repository? These crates will likely need to be updated together. |
|
I can do that if you prefer, it's up to you. My main hesitation was described in #22 (comment)
i.e. moving the entire existing crate into a subdir called string_cache seems like it'd pollute the git history? Or are you suggesting keeping string-cache at the top level, creating a string_cache_codegen subfolder and adding that folder to the |
|
I don't understand the concern with git history. Theses crates are very much related, changes in one are relevant to the other. On the other hand, coordinating PRs that depend on each other across repositories tends to be a pain. I don't care too much about the directory structure within one repository. |
As in, doing I've made the change adding string-cache-codegen as a subfolder. |
82be23e to
ff4d798
Compare
6f65787 to
36184f5
Compare
|
Rebased to fix conflicts. Both crates are within one repo and Cargo.toml at the root level contains I've updated the top PR comment since it was a bit out-of-date. |
Cargo.toml
Outdated
| phf_generator = "0.7.4" | ||
| phf_shared = "0.7.4" | ||
| [build-dependencies.string_cache_codegen] | ||
| version = "0.2.11" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably need to specify path = "string-cache-codegen" here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that line is noted in the first comment of this PR as part of the instructions for trying it out.
However, I believe that won't work for downloads from crates.io because of exclude = ["string-cache-codegen/**/*"]. I added this exclude line because I think string-cache should consume string-cache-codegen from crates.io (like anything else will need to).
I could
- add
path =to demonstrates the tests pass or - add
path =and removeexclude =for the purposes of this PR, then make a followup PR once string-cache-codegen is published to crates.io undoing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I believe that won't work for downloads from crates.io because of
exclude = ["string-cache-codegen/**/*"]. I added this exclude line because I think string-cache should consume string-cache-codegen from crates.io (like anything else will need to).
I'm pretty sure you just need a path dependency, with no exclude at all, just like phf does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out I didn't understand what path dependencies do (rust-lang/cargo#2625 - when pulling from crates.io, path = are ignored).
I've added path (so tests will work) and left in the exclude (there is no point in users getting the string-cache-codegen folder because Cargo will ignore it).
36184f5 to
4d2419d
Compare
33f805a to
354b7f6
Compare
|
Need to wait for phf 0.7.15 to pick up rust-phf/rust-phf#81 |
c78e9e3 to
f051456
Compare
|
Alright, I'm happy with the state of this PR now the latest phf has been released - could you review? I've been using this locally for a while and it's worked fine, and I've just successfully done a servo build which seems ok (I had to override the path to phf in addition to string-cache because I couldn't seem to get |
|
Did you not have to change html5ever to do a Servo build? If you can push that Servo branch somewhere that would help too. Thanks! |
|
Per message on irc: it was a build from master of servo, no changes required aside from a (when servo takes this update it'll need to update phf to version 0.7.15, but I couldn't figure out how to get mach to do that, per my previous comment) |
|
☔ The latest upstream changes (presumably #165) made this pull request unmergeable. Please resolve the merge conflicts. |
f051456 to
642c066
Compare
|
Rebased. |
|
☔ The latest upstream changes (presumably #166) made this pull request unmergeable. Please resolve the merge conflicts. |
642c066 to
1e96906
Compare
1e96906 to
bd50cea
Compare
bd50cea to
359127a
Compare
|
☔ The latest upstream changes (presumably #167) made this pull request unmergeable. Please resolve the merge conflicts. |
359127a to
125e9dd
Compare
|
Rebased. |
I don't understand this, what's hard to read in that diff? Git handles moves. |
Github has improved their handling of renames in the time since I wrote that (I'm aware the CLI was always fine). It's irrelevant now though since I like the current arrangement and it works fine. |
|
I don't really like when there are crates in subdirectories of another. I would rather we move |
|
To offer a counterargument: the codegen crate is pretty thin, I suspect the majority of people will be interested in the code string-cache itself so it kinda makes it easier having it at the top (the readme can contain details of both crates, I just haven't done it yet). That said, I don't have strong feelings so if that's a consensus among crate maintainers/should be considered a review comment, I'll change it. |
|
So, how's the review coming along? :) I've now finished v0.1 of my project but I can't publish to crates.io with git repositories in the sources. If you think it'll take another few months to get around to reviewing etc I'll just vendor string-cache for a while - no big deal. Just want to get some idea of where this is at. |
This new dependency is temporary. With #136 it’ll go into html5ever.
|
I apologize for procrastinating for so long the review of this PR. There was a number of things that I wanted to change / tweak, so rather than micro-manage a review to make you do them I ended up making a new PR at #178. Few actual lines of code are in common, but the basic idea is the same as in this PR and some of the commits are attributed to you. Of the changes, a big one is not trying to preserve compatibility. One of the goals is to remove the big list of static strings from this crate, so it’s gonna be a breaking change.
The I made the codegen slightly more ergonomic, and support having the generated code included in a module (not at the crate’s root) by taking a path rather than just an identifier. Closing in favor of #178, thank you for your work! |
Make Atom generic over the set of static strings The new `string_cache_codegen` crate is intended to be used by downstream users in their build scripts. Provided a list of static strings, it generates code that defines: - A type alias for `Atom<_>` with the type parameter set, - A macro like the former `atom!` macro. Based on #136, original work by @aidanhs. Fixes #22, fixes #136, closes #83. r? @nox <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/string-cache/178) <!-- Reviewable:end -->
Test fails because the string-cache-codegen subfolder needs to be released to crates.io
All tests pass down to rust 1.4.0.
Some notes on string_cache:
extern crate phfwhen doing codegenSTATIC_ATOM_SETdirectly or calling any methods on it yourself -atom!etc will still work for all of the servo-specific atomsSomeAtom::from(whereSomeAtomisAtomor some other type generated by string_cache_codegen) will either return a static atom from the static string set corresponding to that type, or will insert a dynamic atom into a dynamic string cache shared among all atom kindsSome specific notes on string_cache_codegen:
phfcrate (i.e. atstring_cache::shared::phf). The motivation was to not require users of string_cache_codegen to depend on phf themselves.If you want to try it out, you just need to checkout my branch and add
path = "string-cache-codegen"to the end of the root Cargo.toml. You can now runcargo buildin the repo root (to test new static atom generation for string_cache) and the string_cache_codegen subfolder (to check it builds). You can also runcargo testin the root folder and string_cache_codegen/test subfolders and it should all work.