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

Update hyper to latest nightly #324

Closed
wants to merge 9 commits into from

Conversation

renato-zannon
Copy link
Contributor

This makes hyper compile again under the recent Send changes, which just landed on nightly. I also addressed a few new warnings.

I tried to address the comment on server/acceptor.rs:26, but was unable to do so. It seems that I need to improve my lifetime-fu :)

@renato-zannon
Copy link
Contributor Author

Seems that travis' rust is outdated. I tested on rustc 1.0.0-nightly (dfc5c0f1e 2015-02-18) (built 2015-02-19)

@Byron
Copy link
Contributor

Byron commented Feb 20, 2015

When using the compiler version mentioned by @renato-zannon, the build, tests and benchmarks work for me too.

@Byron
Copy link
Contributor

Byron commented Feb 20, 2015

Oh, actually, the benchmarks seem to hang, like a deadlock of some sort. I am on OSX 10.10.2, in case it matters. Also it's the first time I am running hyper benchmarks, and thus can't tell if this hang is new.
I will keep going, in the hopes that this is just a bug in the benchmarks.

@reem
Copy link
Contributor

reem commented Feb 20, 2015

@renato-zannon I may have been premature with that comment. Unless we want accept to block and for us to run it in another thread explicitly, we need to use Arc.

work: F,
threads: usize) -> JoinGuard<'static, ()> {
pub fn accept<F>(self, work: F, threads: usize) -> JoinGuard<'static, ()>
where F: Fn(A::Stream) + Send + Sync + 'static {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional advantage of making this blocking: 'a here instead of 'static, so this can be used with non-'static data.

… data

Change AcceptorPool to not spawn detached threads anymore. This,
together with the recent `Send` changes, allows the `work` closure to
close over non-`'static` data.

This doesn't change the high-level `Server` interface, because that
would make it's `listen` a blocking call (it's currently non-blocking)
- which would be a breaking change.
@renato-zannon
Copy link
Contributor Author

@reem I tried to address your comments on the last commit. I refrained from changing the non-blocking behavior of Server::listen - even though that would be necessary to make it possible to close over non-``static` data - because that would be a breaking change. It should be relatively straightforward to do though, and I would be happy to do it.

@reem
Copy link
Contributor

reem commented Feb 21, 2015

Looks like good work, but there is still another error.

@seanmonstar
Copy link
Member

An error about IntoCow, it looks like? And all those warnings about the
changed slice syntax will be errors in 'cargo test'...

On Fri, Feb 20, 2015, 11:58 PM Jonathan Reem notifications@github.com
wrote:

Looks like good work, but there is still another error.


Reply to this email directly or view it on GitHub
#324 (comment).

@renato-zannon
Copy link
Contributor Author

Those are from a recent breaking change. I'll download the new nightly and fix that!

@renato-zannon
Copy link
Contributor Author

@reem I've updated the PR again even though it is still WIP, because there's an an error I haven't been able to figure out by myself - from lines 252 to 256 on src/lib.rs:

#[allow(unconditional_recursion)]
fn _assert_send<T: Send>() {
    _assert_send::<client::Request<net::Fresh>>();
    _assert_send::<client::Response>();
}

Error:

src/lib.rs:254:5: 254:48 error: the trait `core::marker::Send` is not implemented for the type `<str as collections::borrow::ToOwned>::Owned` [E0277]
src/lib.rs:254     _assert_send::<client::Request<net::Fresh>>();
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib.rs:254:5: 254:48 note: `<str as collections::borrow::ToOwned>::Owned` cannot be sent between threads safely
src/lib.rs:254     _assert_send::<client::Request<net::Fresh>>();
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If I comment these lines out, hyper compiles, and all tests pass.

BTW: turns out there were lots of breaking changes on the nightly. Let me know if I should squash all these fix(rustup) commits.

@reem
Copy link
Contributor

reem commented Feb 21, 2015

After we're done reviewing and are ready to merge you'll squash.

@renato-zannon
Copy link
Contributor Author

Boiled this down to Cow<'static, str>. This doesn't compile:

#[allow(unconditional_recursion)]
fn _assert_send<T: Send>() {
    use std::borrow::Cow;
    _assert_send::<Cow<'static, str>>();
}

Fails with:

src/lib.rs:256:5: 256:38 error: the trait `core::marker::Send` is not implemented for the type `<str as collections::borrow::ToOwned>::Owned` [E0277]
src/lib.rs:256     _assert_send::<Cow<'static, str>>();
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lib.rs:256:5: 256:38 note: `<str as collections::borrow::ToOwned>::Owned` cannot be sent between threads safely
src/lib.rs:256     _assert_send::<Cow<'static, str>>();
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `hyper`.

Even though this compiles fine:

#[allow(unconditional_recursion)]
fn _assert_send<T: Send>() {
    use std::borrow::ToOwned;
    _assert_send::<<str as ToOwned>::Owned>();
}

Which seems contradictory to me.

@softprops
Copy link
Contributor

I updated my cargo config to point to

[dependencies.hyper]
git = "https://github.com/renato-zannon/hyper.git"
rev = "124a31fb9b7363960bebbdcf71df9e1e1cb0e075"

My compiler errors/warnings went down to the following afterwards

error: the trait `core::marker::Send` is not implemented for the type `<str as collections::borrow::ToOwned>::Owned` [E0277]
 _assert_send::<client::Request<net::Fresh>>();
note: `<str as collections::borrow::ToOwned>::Owned` cannot be sent between threads safely
 _assert_send::<client::Request<net::Fresh>>();

@@ -22,14 +22,14 @@ impl<S: Scheme> DerefMut for Authorization<S> {
}
}

impl<S: Scheme> Header for Authorization<S> {
impl<S: Scheme + 'static> Header for Authorization<S> where <S as FromStr>::Err: 'static {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, seems odd to need this bound, but I see why. Not something I would immediately think of...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I found this odd too. Took me a while to figure out where to put the bound

@seanmonstar
Copy link
Member

@renato-zannon This is awesome, thanks! I realize this can be tedious work (updating for syntax changes).

I've fixed the last remaining thing, and will merge the new PR that includes your commits and mine. I feel like the commits are sufficiently separated that they can be merged as-is, without squashing.

@seanmonstar
Copy link
Member

Merged as #329

@renato-zannon
Copy link
Contributor Author

@seanmonstar Cool :) Even though they can be a bit tedious, these changes are a great way to get early exposure to the codebase. Maybe in the future I'll be able to submit more interesting PRs :)

@softprops
Copy link
Contributor

Thanks for patching this up quickly. You guys are awesome

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.

5 participants