-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(client): make RequestBuilder non-generic
Improve the compile-time of downstream crates that use RequestBuilder, by not forcing them to remonomorphise and recompile its non-generic methods when they use it: with this change, they can just call the precompiled versions in the `hyper` object file(s). The `send` method is the major culprit here, since it is quite large and complicated. For an extreme example, extern crate hyper; fn main() { hyper::Client::new().get("x").send().unwrap(); } takes ~4s to compile before this patch (i.e. generic RequestBuilder) and ~2s after. (The time spent interacting with LLVM goes from 2.2s to 0.3s.) BREAKING CHANGE: `RequestBuilder<U>` should be replaced by `RequestBuilder`.
- Loading branch information
Showing
1 changed file
with
24 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
ff4a607
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.
After this change it's not possible to use
url::Url
as input toclient.get()
. Instead a&str
is needed. Sourl::Url
has to be serialised first which implies an allocation.ff4a607
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.
@maximih Do you have the error message? The bounds haven't changed for
get
?Are you having an issue with crates mismatching for
url
perhaps?ff4a607
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 are right. It seems to have something to do with
url
crate. Sorry for the false alarm.It works fine if I force the
url
crate version:url = "=0.2.38"
.If I use
url = "*"
(which translates to url version 0.5.0), I get this error:I had a quick look over the changes in the
url
crate and they don't seem related to this issue. So, no idea really why this happens.ff4a607
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.
Rust sees two different versions of the same crate as entirely different types, so when hyper implements a trait for the version that it imports, the trait is only implemented for that specific version of
url::Url
.ff4a607
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.
Thanks for the clarifications. This is very good to know!
Somehow I managed to avoid this problem before even though I use wildcards for most of my dependencies so that I get latest updates using
cargo update
, without changingCargo.toml
. Time to move to specific versions.