Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMove to cargo workspaces and single toplevel Cargo.lock #12391
Conversation
highfive
commented
Jul 11, 2016
|
Heads up! This PR modifies the following files:
|
Ah yeah
It should be the case that
Hehe, indeed! That's due to this PR which guarantees that the root of a lock file is deterministically chosen. Looks like though I accidentally chose In any case it shouldn't matter in general hopefully! |
Hrm, that's not going to work, as we only And that sounds fine on the other two points - thanks! :-) |
|
Could the |
|
|
|
@SimonSapin @emilio What is the plan for According to @alexcrichton, our current I suppose that we could clone both versions in, do a top-level |
|
@larsbergstrom: TL;DR; I don't think it can be upstreamed without headache. So the point of it as far as I know is to be a drop-in replacement for While moving it to the main We could try to split this dependency, I guess, but this would be at the cost of even more unsafety and pointer casting in the geckolib side, and more maintenance burden for
So yeah, IMO moving it into |
|
In the current setup, this replacement is only essential for the But with use string_cache::BorrowedAtom;
pub trait Element {
// Other things…
fn get_local_name<'a>(&'a self) -> BorrowedAtom<'a>;
}Without the So we’d need either:
|
|
We could also just make |
|
BorrowedAtom isn't an optimization over &'a Atom, it's an optimization over Atom. Returning a &'a Atom isn't acceptable for the Gecko case because returning a pointer to a pointer in an unowned data structure is terrifying without the support of borrowck. @nox makes a good point about the static atoms, but I'm assuming this was a measured optimization, so presumably it helped some how. |
|
Also, we definitely want our string_cache override to live in geckolib (and depend on gecko_bindings), and I don't think we should block on new language features for this. |
|
I got another fancy idea. In the trait: type LocalName: Borrow<Atom>;In Servo impl: type LocalName = Atom;In Gecko impl: type LocalName = BorrowedAtom;With: pub struct BorrowedAtom(UnsafeCell<()>);
impl Borrow<Atom> for Name {
fn borrow(&self) -> &Atom {
/* SOME TRANSMUTE MAGIC I GOT WRONG AGAIN DISREGARD ME */
}
}Then in the |
|
@bholley Is returning a
I’m assuming this was not measured. IMO it’s fairly idiomatic Rust to try to avoid |
|
Given that these calls are hot (I've certainly seen them in the profiles), I'd still rather avoid cloning, because even if the reference counting is a no-op for static atoms, we still need to do FFI calls to do it in geckolib. So I guess it matters whether or not it was a measured optimization for servo. :-P What about @nox's idea? |
|
@nox's idea is not even doable so forget about it. |
|
Another idea, inspired by rust-lang/rfcs @ #1598 (comment) and https://github.com/nikomatsakis/nll/blob/master/graph-algorithms/src/lib.rs, partially implemented at servo/rust-selectors@f283d1a: pub trait SelectorImpl
where Self: for<'a> BorrowedNamespaceConstructor<'a> {
// ...
}
pub trait BorrowedNamespaceConstructor<'a> {
type BorrowedNamespace: PartialEq<string_cache::Namespace> + PartialEq;
}
pub trait Element {
type Impl: SelectorImpl;
// ...
fn get_namespace<'a>(&'a self) -> <Self::Impl as BorrowedNamespaceConstructor<'a>>::BorrowedNamespace;
}pub struct ExampleSelectorImpl;
impl<'a> BorrowedNamespaceConstructor<'a> for ExampleSelectorImpl {
type BorrowedNamespace = string_cache::BorrowedNamespace<'a>;
}
impl SelectorImpl for ExampleSelectorImpl {
// ...
} |
|
Note that if it's too onerous to push around the dependencies, it makes sense to me that projects in a workspace may have different |
|
If we do @SimonSapin's idea, does that mean that we can move the static atom list into servo/servo? That would be super-duper awesome, because right now adding atoms to the list involves publishing an update on crates.io, which makes it very tempting to just use a dynamic atom where we should use a static one. |
|
@bholley There are ideas around to have sets of static atoms defined outside of the But I think it’s all largely independent from making |
Make the style crate more concrete Background: The changes to Servo code to support Stylo began in the `selectors` crate with making pseudo-elements generic, defined be the user, so that different users (such as Servo and Gecko/Stylo) could have a different set of pseudo-elements supported and parsed. Adding a trait makes sense there since `selectors` is in its own repository and has others users (or at least [one](https://github.com/SimonSapin/kuchiki)). Then we kind of kept going with the same pattern and added a bunch of traits in the `style` crate to make everything generic, allowing Servo and Gecko/Stylo to do things differently. But we’ve also added a `gecko` Cargo feature to do conditional compilation, at first to enable or disable some CSS properties and values in the Mako templates. Since we’re doing conditional compilation anyway, it’s often easier and simpler to do it more (with `#[cfg(feature = "gecko")]` and `#[cfg(feature = "servo")]`) that to keep adding traits and making everything generic. When a type is generic, any method that we want to call on it needs to be part of some trait. ---- The first several commits move some code around, mostly from `geckolib` to `style` (with `#[cfg(feature = "gecko")]`) but otherwise don’t change much. The following commits remove some traits and many type parameters through the `style` crate, replacing them with pairs of conditionally-compiled API-compatible items (types, methods, …). Simplifying code is nice to make it more maintainable, but this is motivated by another change described in #12391 (comment). (Porting Servo for that change proved difficult because some code in the `style` crate was becoming generic over `String` vs `Atom`, and this PR will help make that concrete. That change, in turn, is motivated by removing geckolib’s `[replace]` override for string-cache, in order to enable using a single Cargo "workspace" in this repository.) r? @bholley --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require new tests because refactoring <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12515) <!-- Reviewable:end -->
Implement Default and PartialEq<String>. This is part of the changes proposed at servo/servo#12391 (comment) <!-- 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/165) <!-- Reviewable:end -->
|
r? @nox (or anybody) for just the cargo version update. r=SimonSapin once that is done! |
|
@bors-servo r=SimonSapin,Manishearth |
|
|
| env=self.build_env()) | ||
| with cd(self.context.topdir): | ||
| call(["cargo", "update"] + params, | ||
| env=self.build_env()) |
This comment has been minimized.
This comment has been minimized.
aneeshusa
Aug 25, 2016
Member
GH won't let me leave a comment there, but does this need to be updated in ./mach fetch as well? Can CARGO_PATHS be deleted?
This comment has been minimized.
This comment has been minimized.
larsbergstrom
Aug 25, 2016
Author
Contributor
fetch is still project-specific, based on my local testing, which is why I didn't do it over there.
…anishearth Move to cargo workspaces and single toplevel Cargo.lock This seems to work except for a couple of things I'd like feedback from @alexcrichton on: 1) ports/geckolib/Cargo.toml has a `[replace]` block, but that seems to be getting ignored when being built as part of a workspace. You can repro by doing `./mach build-geckolib` from the root - you'll get: ``` [larsberg@larsberg servo]$ ./mach build-geckolib Compiling string_cache v0.2.20 /Users/larsberg/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/string_cache-0.2.20/src/lib.rs:15:35: 15:64 error: #[feature] may not be used on the stable release channel /Users/larsberg/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/string_cache-0.2.20/src/lib.rs:15 #![cfg_attr(feature = "unstable", feature(unsafe_no_drop_flag))] ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: aborting due to previous error error: Could not compile `string_cache`. To learn more, run the command again with --verbose. GeckoLib build completed in 0:00:01 [larsberg@larsberg servo]$ ``` 2) Is the right way to perform a `cargo update` still to go to each of the workspaces and perform the update there? That seems to be the only way that works - we get an error if we do it at toplevel. 3) Minor: the `[root]` name is `webdriver_server`, which seems... really weird. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12391) <!-- Reviewable:end -->
|
|
|
Looks like two failures:
And not getting built to |
|
Unless the duplicate version is easy to fix let’s add an exception in tidy. |
|
|
|
The main things to do here are:
|
|
Superseded by #14381. |
…concrete-style); r=bholley Background: The changes to Servo code to support Stylo began in the `selectors` crate with making pseudo-elements generic, defined be the user, so that different users (such as Servo and Gecko/Stylo) could have a different set of pseudo-elements supported and parsed. Adding a trait makes sense there since `selectors` is in its own repository and has others users (or at least [one](https://github.com/SimonSapin/kuchiki)). Then we kind of kept going with the same pattern and added a bunch of traits in the `style` crate to make everything generic, allowing Servo and Gecko/Stylo to do things differently. But we’ve also added a `gecko` Cargo feature to do conditional compilation, at first to enable or disable some CSS properties and values in the Mako templates. Since we’re doing conditional compilation anyway, it’s often easier and simpler to do it more (with `#[cfg(feature = "gecko")]` and `#[cfg(feature = "servo")]`) that to keep adding traits and making everything generic. When a type is generic, any method that we want to call on it needs to be part of some trait. ---- The first several commits move some code around, mostly from `geckolib` to `style` (with `#[cfg(feature = "gecko")]`) but otherwise don’t change much. The following commits remove some traits and many type parameters through the `style` crate, replacing them with pairs of conditionally-compiled API-compatible items (types, methods, …). Simplifying code is nice to make it more maintainable, but this is motivated by another change described in servo/servo#12391 (comment). (Porting Servo for that change proved difficult because some code in the `style` crate was becoming generic over `String` vs `Atom`, and this PR will help make that concrete. That change, in turn, is motivated by removing geckolib’s `[replace]` override for string-cache, in order to enable using a single Cargo "workspace" in this repository.) r? bholley --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require new tests because refactoring <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 2d01d41a506bcbc7f26a2284b9f42390d6ef96ab UltraBlame original commit: c240fafa26f6fdedc44dd6c3a7f3d172536e6b87
…(from servo:selectors-generic-atom_); r=bholley This removes the `[replace]` override in geckolib and therefore unblocks servo/servo#12391. This includes the `gecko_string_cache` redesign discussed in servo/servo#12548. r? bholley --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #12548 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require new tests because refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 5e83b3f83bfcf48d0096442bdf5c9bf753623970 UltraBlame original commit: db13dfd0cfa9ee8de452d6083c2d5bdda74585af
…concrete-style); r=bholley Background: The changes to Servo code to support Stylo began in the `selectors` crate with making pseudo-elements generic, defined be the user, so that different users (such as Servo and Gecko/Stylo) could have a different set of pseudo-elements supported and parsed. Adding a trait makes sense there since `selectors` is in its own repository and has others users (or at least [one](https://github.com/SimonSapin/kuchiki)). Then we kind of kept going with the same pattern and added a bunch of traits in the `style` crate to make everything generic, allowing Servo and Gecko/Stylo to do things differently. But we’ve also added a `gecko` Cargo feature to do conditional compilation, at first to enable or disable some CSS properties and values in the Mako templates. Since we’re doing conditional compilation anyway, it’s often easier and simpler to do it more (with `#[cfg(feature = "gecko")]` and `#[cfg(feature = "servo")]`) that to keep adding traits and making everything generic. When a type is generic, any method that we want to call on it needs to be part of some trait. ---- The first several commits move some code around, mostly from `geckolib` to `style` (with `#[cfg(feature = "gecko")]`) but otherwise don’t change much. The following commits remove some traits and many type parameters through the `style` crate, replacing them with pairs of conditionally-compiled API-compatible items (types, methods, …). Simplifying code is nice to make it more maintainable, but this is motivated by another change described in servo/servo#12391 (comment). (Porting Servo for that change proved difficult because some code in the `style` crate was becoming generic over `String` vs `Atom`, and this PR will help make that concrete. That change, in turn, is motivated by removing geckolib’s `[replace]` override for string-cache, in order to enable using a single Cargo "workspace" in this repository.) r? bholley --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require new tests because refactoring <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 2d01d41a506bcbc7f26a2284b9f42390d6ef96ab UltraBlame original commit: c240fafa26f6fdedc44dd6c3a7f3d172536e6b87
…concrete-style); r=bholley Background: The changes to Servo code to support Stylo began in the `selectors` crate with making pseudo-elements generic, defined be the user, so that different users (such as Servo and Gecko/Stylo) could have a different set of pseudo-elements supported and parsed. Adding a trait makes sense there since `selectors` is in its own repository and has others users (or at least [one](https://github.com/SimonSapin/kuchiki)). Then we kind of kept going with the same pattern and added a bunch of traits in the `style` crate to make everything generic, allowing Servo and Gecko/Stylo to do things differently. But we’ve also added a `gecko` Cargo feature to do conditional compilation, at first to enable or disable some CSS properties and values in the Mako templates. Since we’re doing conditional compilation anyway, it’s often easier and simpler to do it more (with `#[cfg(feature = "gecko")]` and `#[cfg(feature = "servo")]`) that to keep adding traits and making everything generic. When a type is generic, any method that we want to call on it needs to be part of some trait. ---- The first several commits move some code around, mostly from `geckolib` to `style` (with `#[cfg(feature = "gecko")]`) but otherwise don’t change much. The following commits remove some traits and many type parameters through the `style` crate, replacing them with pairs of conditionally-compiled API-compatible items (types, methods, …). Simplifying code is nice to make it more maintainable, but this is motivated by another change described in servo/servo#12391 (comment). (Porting Servo for that change proved difficult because some code in the `style` crate was becoming generic over `String` vs `Atom`, and this PR will help make that concrete. That change, in turn, is motivated by removing geckolib’s `[replace]` override for string-cache, in order to enable using a single Cargo "workspace" in this repository.) r? bholley --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require new tests because refactoring <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 2d01d41a506bcbc7f26a2284b9f42390d6ef96ab UltraBlame original commit: c240fafa26f6fdedc44dd6c3a7f3d172536e6b87
…(from servo:selectors-generic-atom_); r=bholley This removes the `[replace]` override in geckolib and therefore unblocks servo/servo#12391. This includes the `gecko_string_cache` redesign discussed in servo/servo#12548. r? bholley --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #12548 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require new tests because refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 5e83b3f83bfcf48d0096442bdf5c9bf753623970 UltraBlame original commit: db13dfd0cfa9ee8de452d6083c2d5bdda74585af
…(from servo:selectors-generic-atom_); r=bholley This removes the `[replace]` override in geckolib and therefore unblocks servo/servo#12391. This includes the `gecko_string_cache` redesign discussed in servo/servo#12548. r? bholley --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #12548 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require new tests because refactor <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 5e83b3f83bfcf48d0096442bdf5c9bf753623970 UltraBlame original commit: db13dfd0cfa9ee8de452d6083c2d5bdda74585af
larsbergstrom commentedJul 11, 2016
•
edited
This seems to work except for a couple of things I'd like feedback from @alexcrichton on:
[replace]block, but that seems to be getting ignored when being built as part of a workspace. You can repro by doing./mach build-geckolibfrom the root - you'll get:Is the right way to perform a
cargo updatestill to go to each of the workspaces and perform the update there? That seems to be the only way that works - we get an error if we do it at toplevel.Minor: the
[root]name iswebdriver_server, which seems... really weird.This change is