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
[WIP] Make it build with Rust 1.0.0-alpha #135
Conversation
b1e3963
to
70075e2
Compare
Not ready yet, but more progress |
I saw that the dependencies broke today again. I updated them so we can keep working on this. Are you still working on this @rgs1? If not I might try to finish it during the weekend. |
Ok so @rgs1 I have fixed most the errors from the latest nightly, but I have no idea what the following construct's are doing so I don't even know how to begin to fix them.
If you can point me in the direction of what that language construct even is I can have a pull request for you that should fix all the build errors. |
You must have edited that line. What it originally says is What that is supposed to do is the following:
I assume the confusion comes from the fact that you have edited the line. I'm super glad to see new contributors by the way! |
Ah very nice @dkhenry! I'll resume this today! |
👍 |
5c1b4ba
to
1e8b7ff
Compare
Ok! It builds! It's not ready for merge because there are some inefficient things (i.e.: assigning a Regex::new to a static inside a mod is not working for me, need to dig in) plus in general things are not super tidy. I also haven't touched the tests. I'll make a 2nd pass now to get things in order, unless someone gets there first. |
(I updated the branch, but it's still WIP) |
1e8b7ff
to
b5b665e
Compare
Ah, so regex! is available via a separate lib (plugin), regex_macros. So the static issue is fixed, next warnings + tests! |
b5b665e
to
9c55393
Compare
No more warnings! Only tests are left to be fixed! |
Beautiful! I will have a look at the code later (as will the others, I'm sure. @Ryman always manage to find some nitpicks :) ). When you feel that you're done, would you mind naming your commit according to the following conventions? I forgot to tell you on your last commit but we're looking at automatically generating a changelog in the future. |
9c55393
to
4379c55
Compare
Tests build!! They don't pass though :-) But I think I mostly know why. Going out for a run and will fix them when I get back. Almost there! Stay tuned |
You have changed the mutability on the And what's up with storing the handler in a variable like that? Are you sure issue #15444 is related? Because this was working a month and a half ago and that issue is older, no? |
Oops, sorry about the unneeded mut. Sure I'll fix all the unneeded stuff on a final pass (making tests pass now). Wrt to coercing handlers, I couldn't find another way to make it work with nightly. Here's a toy example: http://is.gd/H60Xjl. I asked around #rust, and they say it'll get fix at some point. |
No worries. Sounds good! Yeah, I also figured that it must be a bit of a bug in the compiler. I questioned whether issue #15444 that you mentioned in a comment is the one to blame, as that issue dates from before this stopped working. Anyways, we have the We'll have to remember to revert the examples once this gets fixed in the compiler just. |
Yup I'll try to find the actual real/current issue in so we can mention that in the FIXMEs |
4379c55
to
eb6140e
Compare
All tests passing! Now, we can do some real review @simonpersson ;-) Up next:
Please feel free to point out nits (and not nits) so we can get this in good shape. Thanks! |
eb6140e
to
f1484ff
Compare
Updated the commit message according to the used convention + drop the unneeded &mut changes. Should be ready-ish for merge hopefully. |
Yay! Travis passed too, great news. The Some calls to Line 140 in Other than these things, I think this looks great! I'd like to hear the opinion of @Ryman or @cburgdorf before merging though, |
Great, thanks for the review! I'll take a look in a bit, all of those are probably left over or omissions. |
Wrt to the rust-http issue, in nickel-org/rust-http@53d30c0 I wonder if: -impl fmt::Show for Status {
+impl fmt::Display for Status {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, \"{} {}\", self.code(), self.reason())
} has something to do. |
server.utilize(logger); | ||
// issue #15444 | ||
let logger_handler: fn(&Request, &mut Response) -> MiddlewareResult = logger; | ||
server.utilize(logger_handler); |
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.
server.utilize(logger as fn(&Request, &mut Response) -> MiddlewareResult);
is the common form of this last I saw, but it's still horrible :(
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.
So I guess we leave it as is and revisit later on when the variants of rust-lang/rust#20178 are done?
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.
I think it's worth trying (this could go in nickel/lib.rs with a doccomment explaining its purpose):
type HandlerPtr = fn(&Request, &mut Response) -> MiddlewareResult
and changing fallout code to:
foo(bar as HandlerPtr)
OR I think changing the naming convention, logger_handler
=> logger_fnptr
.
I guess it's a nit really, but I'm guessing people may understand a cast to a function pointer if they come from c++/c rather than reading 'I'm turning my handler into a handler..?' and perhaps being confused.
Added a few inline comments, looks good other than that, and we can iterate easier once master's buildable :) I've let an old branch porting to hyper bitrot, might try to rebase onto this sometime soon. Thanks for the efforts @rgs1! |
@simonpersson: thanks! Though Show is deprecated and was split into Debug and Display. I think we want both for status (i.e.: impl Display and derive Debug). We can follow-up in that repo. @Ryman: thanks for the review! I'll get to that a bit later, would be great to have master be buildable again! |
d1b6931
to
6b4df67
Compare
Updated to conform with @Ryman's review - let me know how it looks now. |
@rgs1 Thanks, I think I checked all the changes, still a few outstanding nits. In future, could you make changes in new separate commits that can be squashed later, as it helps to minimize incremental review time. 👍 |
Added two commits to address the last two comments. Shall we wait for @simonpersson to weight in on how to handle the casts? Note that the last two commits don't adhere to the usual commit formatting, since we'll probably squash them. Thanks for the review @Ryman. |
LGTM once there's a consensus on the casting/ergonomics issue :) |
Have we tried declaring a type for easier casting? If it works it is prettier I suppose. On the other hand, it's not meant to be a permanent solution anyways and there's still the So, it doesn't really matter to me :) |
I assume we'll be tracking nightly from now on, so things will be in a state of flux anyway. As soon as this is fixed in the compiler, we can change it. |
A bunch of things need to happen so that all plays nicely with latest rust nightly: - Middleware impls need to be coerced (variant of issue #20178) - Regex is now an external lib - A bunch of compiler directive got renamed/changed (i.e.: deriving -> derive, feature(phase) is gone, phase(plugin) is just #[plugin], etc. - Use BTreeMap instead of plain TreeMap - Use #![allow(unstable)] to silence warnings - std::sync::atomic::Relaxed is now std::sync::atomic::Ordering::Relaxed - Int types got renamed and regroupd (i.e.: uint -> usize, u -> us, etc) - Show trait got split into Display and Debug - The plugin lib changed its API - Closures need |&:| to hint they are FnShare - Slice methods are deprecated in favor of &[..] - Occupied and Vacant moved: std::collections::{hash_map, Entry::} Signed-off-by: Raul Gutierrez S <rgs@itevenworks.net>
99df6df
to
ae2c49e
Compare
Squashed @simonpersson @Ryman ! |
Awesome work @rgs1 :) |
Bring nickel up to Rust 1.0.0-alpha
Merged, thanks for the work @rgs1! 👍 |
WIP: don't pull yet
Signed-off-by: Raul Gutierrez S rgs@itevenworks.net