-
Notifications
You must be signed in to change notification settings - Fork 51
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
Port tower-web to Edition 2018 #209
Conversation
- Run the `cargo fix --edition` - Cargo.toml - add `edition = 2018`
Looks good to me. Do you think you can port |
It looks like Other than that it might also be worth including the edition idiom fixes? It builds fine after |
CI failed because the minimum compiler version needs to be bumped. |
Can you expand a bit more what you mean? One big point of the edition system is that libraries written in either edition can work with users in any edition. Even if the library was written using the 2015 edition, it can still be used by 2018 (and vice versa).
|
I also recommend adding |
This isn't correct as it's not in stable, but it has been stabilized. Rust 1.34.1 is the current stable version and does not have this functionality. |
|
Sure, I don't intend to be dismissive. My point is that the premise expressed in the comment is incorrect. If the crate wants to be updated (and require the requisite compiler upgrades), then this is a good step towards that. |
Edition related issue. I am working in 2018 with nightly with the
I would suggest to run with this PR and I can update the |
Yes, using
I'd actually expect that the error you report is because the crate where you are using tower-web doesn't have edition 2018 enabled in the Cargo.toml. |
Yeah,
I think The use futures::Future;
use std::future::Future as StdFuture;
async fn map_ok<T, E>(future: T) -> Result<T::Output, E>
where
T: StdFuture,
{
Ok(await!(future))
} |
@shepmaster Since it's trying to compile Edit: @lnicola Let me then port the macros and run idioms |
Right, which are only enabled if the user opts-in to them: Lines 33 to 34 in c2fbd0b
What I'm not understanding is how did this ever work? Did a previous version of the compiler allow |
- Fix code for 2018 Edition - Cargo.toml - set edition to 2018
Basically yes, when feature-gated off. Now it's a parsing error, apparently. See #193 and #192. |
@lnicola and @shepmaster Thanks a lot for the quick feedback. Whenever I can I help, I've just started with Rust, but I am really happy that I can contribute even with small piece. I hope these are all required changes from my side in order not to fail the build. |
@carllerche Do you think it's worth putting out a breaking release for this and #201 and #182? I'd be inclined to say yes, since people will be wanting to play with I updated |
Thanks @lnicola ! I didn't know if it's ok just to bump it or try to run it nightly on 1.29 :D not sure even if it would work. |
Sure, #194 would be nice. But I don't know how to implement it 😄, and @carllerche probably doesn't have time for it right now. |
Whoops, there is an issue now running the example that I've just found.
|
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.
We should probably update the example to the new syntax.
@elpiel which imports do you mean? |
@lnicola I can look at that tomorrow.
See my comment at #77 (comment) . |
You can simply replace |
@elpiel The macro uses a ton of hacks to work around lack of proc attr macros (when it was first written). The best strategy there would be to switch to proc macros. |
@lnicola will do that now.
Instead of this:
before it is rewritten with proc macros? |
@elpiel yes, that is fine w/ me. |
@lnicola because tokio, latest nightly fails (the example):
I think we should wait (pun intended) for this to be resolved?! Otherwise I don't know if I want to go into pulling the tokio branch to check if this works. Currently it works with I can add the rust-toolchain for the example and mention it in the README? |
Yes, unfortunately Tokio will probably not track further nightly changes on 0.1. |
Is there a non-0.1 |
@lnicola work is starting. |
Without this PR, |
I still can add the |
Please don't force a toolchain version. That's the application's decision. |
I don't think that a |
It's also only for the example. As it's a separate project by it's own it shouldn't affect it right? I haven't tried it thought. |
If it's only for the example, I don't have anything against it. |
- Update README to reflect the required nightly version - Add rust-toolchain with the specific version
@lnicola can you check the latest commit? I was wondering if the examples should also be kept in 2015 edition style, but I think this can go to another PR 😛 |
It's fine. By 2015 you mean |
Ready to go in that case! 🎉 |
@carllerche, @shepmaster anything against merging this? |
Based on my skimming of the changes, it seems fine. |
Based on the tentative positive review of @shepmaster I'll merge this 😅. Thanks, @elpiel. |
Port tower-web to Edition 2018
Since I needed it to work with 2018 edition I've spend 10-15 minutes just porting it and at the end the async/await example also works!
I've just ran the
cargo fix --edition
and fixed one place where::Error
was left.The rest was just changing the example and the Cargo.toml of the project and the example.
Plus the features
futures_api
is not necessary any more.Fixes #192 (comment)