Rocket: Compile with stable Rust

Created on 21 Oct 2016  Β·  110Comments  Β·  Source: SergioBenitez/Rocket

The following features need to be stabilized before Rocket can compile on stable:

  • [x] proc_macro_hygiene (rust-lang/rust#54727)
  • [x] associated_consts (rust-lang/rust#29646)
  • [x] conservative_impl_trait (rust-lang/rust#34511)
  • [x] drop_types_in_const (rust-lang/rust#33156)
  • [x] more_io_inner_methods (rust-lang/rust#41519)
  • [x] pub_restricted (rust-lang/rust#32409)
  • [x] struct_field_attributes (rust-lang/rust#41681)
  • [x] use_extern_macros (rust-lang/rust#35896)
  • [x] fn_box (rust-lang/rust#28796)
  • [x] try_from (rust-lang/rust#33417)

The following dependencies rely on nightly features and must be updated before Rocket can compile on stable:

  • [x] pear (https://github.com/SergioBenitez/Pear/commit/333c9bf5e2c516c23b17c7482b410f1448c1b3af)

Update (Feb 07, 2017): Added list of features used by Rocket.
Update (Feb 28, 2017): Added lookup_host feature.
Update (Mar 21, 2017): pub_restricted was stabilized!
Update (Mar 30, 2017): Added never_type feature.
Update (Apr 16, 2017): Added concat_idents feature.
Update (May 19, 2017): Added struct_field_attributes and more_io_inner_methods features.
Update (May 19, 2017): concat_idents is no longer used.
Update (May 19, 2017): Added links to tracking issues.
Update (May 20, 2017): type_ascription is no longer used.
Update (Jun 19, 2017): struct_field_attributes was stabilized!
Update (Jun 24, 2017): Added try_trait feature.
Update (Jul 1, 2017): more_io_inner_methods was stabilized!
Update (Jul 9, 2017): associated_consts was stabilized!
Update (Sep 7, 2017): lookup_host is no longer used.
Update (Sep 14, 2017): drop_types_in_const was stabilized!
Update (Sep 14, 2017): Added decl_macro feature.
Update (Mar 26, 2018): conservative_impl_trait, never_type, and i128_type were stabilized!
Update (Apr 22, 2018): Added fnbox feature.
Update (Apr 26, 2018): never_type stabilization was reverted (rust-lang/rust#50121).
Update (May 5, 2018): Swapped macro_reexport for use_extern_macros.
Update (Jul 29, 2018): Added crate_visibility_modifier and try_from features.
Update (Aug 5, 2018): custom_derive is no longer used.
Update (Aug 17, 2018): use_extern_macros was stabilized!
Update (Sep 3, 2018): const_fn is no longer used.
Update (Sep 26, 2018): Added label_break_value feature.
Update (Oct 9, 2018): Removed compiler plugin features (custom_attribute, plugin).
Update (Oct 9, 2018): Updated proc_macro features.
Update (Mar 9, 2019): try_from was stabilized!
Update (Apr 13, 2019): fnbox is no longer used.
Update (Jul 9, 2019): never_type is no longer used.
Update (Jul 19, 2019): decl_macro is no longer used.
Update (Sep 9, 2019): specialization is no longer used.
Update (Sep 10, 2019): label_break_value is no longer used.
Update (Sep 18, 2019): try_trait is no longer used.
Update (Sep 21, 2019): crate_visibility_modifier is no longer used.
Update (May 19, 2020): proc_macro_hygiene was stabilized!
Update (Jul 16, 2020): proc_macro_diagnostics is no longer used.
Update (Jul 16, 2020): proc_macro_span is no longer used.
Update (Jul 21, 2020): pear was updated to be stable-compatible.

Most helpful comment

Thank you, everyone, sincerely. :heart:

All 110 comments

Looks like this primarily depends on https://github.com/rust-lang/rust/issues/38356

(Or syntex)

Syntex should get this onto stable much more quickly, since the macros > 1.1 effort seems to be just beginning to congeal.

https://news.ycombinator.com/item?id=13245975

since the macros > 1.1 effort seems to be just beginning to congeal.

This needs more than macros 1.1, it needs 2.0. (If it only needed 1.1, then it could go stable in 1.15)

I intended > 1.1 to indicate "after 1.1" but that wasn't very clear.
I've seen the procedural macros effect referenced as 1.2 as well as 2.0. 2.0 does make more sense, since it is a much broader scope, as I understand it.

I've started working on getting syntex to work with this until macros are stabilized (which might be a while). I've got time over the holidays from work so I'll post any progress I make!

Rocket uses much more than just plugins from nightly. The set of features Rocket currently uses are:

#![feature(plugin)]
#![feature(custom_derive)]
#![feature(custom_attribute)]
#![feature(specialization)]
#![feature(conservative_impl_trait)]
#![feature(drop_types_in_const)]
#![feature(associated_consts)]
#![feature(const_fn)]

These uses are important and contribute to the pithiness of the API, so they will stick around until they're stabilized. Until then, I don't believe Rocket will run on stable.

With that being said, I believe that the ergonomics of syntex are very poor, and I don't want to recommend a subpar solution to users. I'm all for getting Rocket to work on stable as soon as possible, but I'm not willing to compromise ergonomics and usability to make that happen.

I'm all for getting Rocket to work on stable as soon as possible, but I'm not willing to compromise ergonomics and usability to make that happen.

I'd love to see it go stable as soon as possible, but I feel you've got the right values for the project. Accessibility is arguably more important for web frameworks than it is for other frameworks and libraries.

Just from trying to get it to work with syntex it's hard. I might try some more this week but you're right. It might just be worth it to wait till those features stabilize.

The lookup_host feature can be replaced by the ToSocketAddrs implementation of &str.

Perhaps you could use something like:
https://github.com/Kimundi/rustc-version-rs

In order to allow stable features to compile using stable, but features that require nightly or beta could be used only when compiling from that branch.

Currently using Iron myself and would love to switch but it's a high security project and for security reasons, I want to avoid Rust nightly.

It's been a year since this post originally... seems the check boxes in the original post are accurate?

Seems to me like getting Rocket out of nightly would be a huge boost for Rust in general but especially for Rocket.. the Rocket team or Rust team should really focus on stabilizing these functions (or finding alternatives?).

Why so slow to get there? Have you run this by the Rust higher ups and pushed them a little bit?

i128 just got stabilized will ship in Rust 1.27.0.

I'm really looking forward to using Rocket in production some day, I'm glad to see there's been some progress recently. :)

macro_reexport is now removed(not in nightly yet, incoming breaking change) and subsumed by feature(use_extern_macros) and pub use

https://github.com/rust-lang/rust/pull/49982

@messense PR #624 should handle those changes.

The Rust community is currently in a major push toward releasing the Rust 2018 Edition. Has anybody investigated whether enough features that Rocket depends on in nightly will be available in that edition that the Rocket community could target that release for stable? It seems like it would be a win-win for both efforts if it was remotely feasible.

I glanced at the 2018 feature status and most of the important ones for Rocket are not listed:

  • const_fn
  • decl_macro
  • never_type
  • proc_macro, and several related features such as proc_macro_non_items
  • specialization, which can apparently be worked around, but might be problematic to drop for existing rocket users

That does not necessarily mean that these features will not be stabilized this year, just that they are not being targeted as part of the Edition. async/await, however, is listed, and says 2018 will be the minimum edition. Depending on what async solution is implemented, Rocket might target the 2018 edition to make use of those ergonomics.

That being said, editions are cross-crate compatible. Whether Rocket ends up targeting the 2015 or 2018 edition should not significantly affect projects that use it.

Just noting, proc_macro is in the process of being stabilized: https://github.com/rust-lang/rust/pull/52081

@est31 Unfortunately, the stabilizing subset is extremely limited and insufficient for Rocket's needs.

Now there's an easier way to keep track of these things: https://forge.rust-lang.org/state-of-rust.html

Either way it'd be nice to have a "tentative ETA" for stable Rocket. Even if it's "don't expect less than 2 years" that could help a lot people who might want to select it but wonder about how long they have to suffer in nightly.

@SergioBenitez You should really reach out to the Rust team and ask for them to prioritize these issues, tell them it's holding up release of Rocket. Or maybe someone can volunteer to help fix these issues if they'll help point you in the right direction?

I know that getting Rocket-like web servers was being listed as a high priority for getting Rust adoption and Rocket looks like an otherwise amazing one.

Team can be found here:
https://www.rust-lang.org/en-US/team.html

Have communicated with Brian in the past who seemed particularly good at responding and helping us out on a far less important issue:
https://github.com/brson

FYI, if you don't want to wait to build web services in rust, check out actix. It works on stable rust.

@0xcaff After trying multiple web frameworks, I have to say really like Rocket.
Iron, unfortunately, didn't do it for me...

I'm grateful for the efforts made by the iron team, and I value open source contributor's time as much as the next guy, but for me, I think Rocket suits fits my needs better.

proc_macro has been split into several subtasks -- which one(s) does Rocket depend on?

EDIT: Thanks!

The following workaround has been used by the Amethyst game engine for the absence of a never type

pub enum Never {}

This type can't be instantiated and thus fills the same purpose.

Very happy to see this progressing!
Team Aardwolf appreciates your hard work :D

Given the recent blogpost, shouldn't the milestone on this be 0.5?

@incubus8 see this blog post for details on the plans: https://rocket.rs/v0.4/news/2018-12-08-version-0.4/

gotcha, sorry for the fuzz

@incubus8 see this blog post for details on the plans: https://rocket.rs/v0.4/news/2018-12-08-version-0.4/

Just noting: on the latest nightly uniform_paths were stabilised, together with ability to export macro_rules from modules:

mod foo {
    macro_rules! bar123 { () => {} }
    pub(crate) use bar123 as bar;
}
foo::bar!();

It seems that it may be possible to remove decl_macro feature ( when targeting 2018 edition)

It seems that it may be possible to remove decl_macro feature ( when targeting 2018 edition)

I played with the new export functionality you mention; it's unfortunate that it only works when the application crate targets 2018. I think it would be acceptable to implement the change if 2018 is required for another reason (e.g. async/await). But I wouldn't want to break compatibility with 2015 edition just to avoid decl_macro unless it's the only feature blocking stable, and maybe not even then.

@jebrosen I would suggest avoiding long term reliance on decl_macro; I don't think the language team has any bandwidth to devote the substantial time that decl_macro requires to stabilize it.

std::convert::Infallible is stable in the upcoming release, that should be able to substitute for most uses of the never-type.

^^ I can quickly go through and issue a PR if that's something that's wanted.

At the very least, a PR will make it obvious where it's currently used and whether Infallible can fully replace its uses. It may not be accepted right way, especially if it would break existing code that uses the real never type.

@jebrosen Is there a minimum version Rocket guarantees, or is it just the current version? Asking because the initial checkout and cargo check returns warnings for both try_from and transpose_result. I'll naturally remove those as well if desired.

@jhpratt Only the Infallible change in one PR (at the very least separate commits) will be easier to split up later if we want to.

reqwest is almost stabled It's currently on 0.9.17
https://github.com/seanmonstar/reqwest

And how, if I may ask, is that relevant here?

hello, any update on this?

@sound2gd Rocket itself should be able to compile on stable as of today's release. Codegen is what still needs nightly.

If we wanted to use rocket on stable and we use codegen right now, how hard do you think it would be to remove the codegen usage?

Presumably we could use something like cargo-expand to see the generated code, and then replace the macro invocation with the generated code?

IIRC Some of rocket's regular dependencies in master still use nightly features (most/all fixable by updating to a more recent version) and rocket depends on `rocket_codegen. Therefore it would take some work to actually do so. Using Rocket without codegen is usually recommended against and loses most of Rocket's value-add, so it's not something I'm interested in investing time into in favor of working on async and other improvements for 0.5.

Presumably we could use something like cargo-expand to see the generated code, and then replace the macro invocation with the generated code?

I have usually found this to be impractical for anything other than testing, because you wouldn't want to and can't use the expansion of certain macros like format!(). In principle it could probably be done, but would not be very nice to maintain.

To summarize - it's probably not useful, easy or very maintainable to use rocket without codegen. Makes sense.

Thanks for the clear explanation πŸ‘

never_type will be stabilized 1.41.0, so you can change std::convert::Infallible into !

Is there any chance we could use this trick to remove the dependency on proc_macro_hygiene, and get Rocket compiling on stable?

This reddit discussion suggests that it's a lot simpler than proc-macro-hack.

I think we could use that trick and get halfway there (we will have some diagnostics-related features to work out), but if I'm reading it right it would limit each function from calling routes!() or uri!() once.

Why doesn't Rocket just use proc-macro-hack directly? Implementation difficulty?

@Kampfkarren Read the comment right before yours πŸ™‚

That's in reference to the trick used by RustPython, no? Not proc-macro-hack?

Ah, you're right. Either way, diagnostics would definitely take a big hit.

The limitation I was thinking of was something else and/or outdated - I believe both proc-macro-hack and the "extracted" version of it would be usable. When it comes down to that time, I think we could use this approach while the relevant part of proc_macro_hygiene is unstable.

Status update?

A stabilization PR for the final nightly-only feature Rocket makes use of is under review! Looks like we're within a few months of Rocket compiling on stable in earnest.

Also worth tracking rust-lang/rust#68716, which is necessary to get that part of proc macro hygiene stabilized.

The guide and examples pretty much all still use ![feature(decl_macro)] even though the OP says it's no longer used since July 2019. Removing the ![feature(decl_macro)] line results in failed compiles.

I feel like I'm missing something: Is the decl_macro feature still needed or not? :thinking:

@runiq decl_macro is needed for 0.4. Future versions of rocket (0.5+) won't need it.

Hi, I've been holding off on making a decision about which HTTP framework to use for a project, while quietly watching progress on this one. Are there any updates about getting Rocket to run on stable Rust?

As far as I know, this is currently blocked on the following dependency chain of Rust PRs, which all look well on their way:

To the best of my knowledge that is correct. One has finished FCP, one is currently in it, and the third has yet to begin it.

If all three get merged by June 4, it will land on stable in Rust 1.45 on July 16. The async version of Rocket will then be able to compile on stable, though as far as I know there's no timeframe on a 0.5 release.

The last remaining feature has just been merged! Finally Rocket will be able to compile with stable Rust (1.45).

I'm so happy to read this!!!, I've been tracking this bug for 2 years waiting with hope. good job guys :)

Congratulations 🍾πŸ₯‚

Awesome news πŸ˜ƒ

Update (May 19, 2019): proc_macro_hygiene was stabilized!

We're on 2020 now :wink:

Awesome news. So when will we actually be able to build rocket with rust stable?

July 16th seems to be the day for stable, and June 4th is the day for beta.

Note that those dates also only apply to the upcoming 0.5 release. 0.4 will continue to require nightly for the time being.

Amazing news! Congrats!

this is great news! is there a timeline for 0.5? i've seen the milestone which also seems to contain other features, some of which are already older issues: https://github.com/SergioBenitez/Rocket/milestone/8
would it be possible to make the 0.5 as soon as it contains everything needed to compile on stable (or, right now on beta)? this would be a huge step forward and move the library in the right direction. being able to build on a stable rust release would reduce the efforts for projects trying to use this library.

Hi @SergioBenitez thanks for this project. Given that Rocket depends on Pear, would you mind describing the purpose of Pear a bit in its own README? Seems like some util traits etc. at first glance...but with a good description in the README, perhaps some other contributors can help figure out how to remove the need for nightly there too.

@rayrrr note that @Aaron1011 's links point to an outdated version of pear. In the current master version of pear (which rocket doesn't use yet as it uses the crates.io version), nightly usage has been removed from the pear_codegen crate, as well as core_intrinsics from the pear crate. The only two remaining feature gates are for proc_macro_hygiene, removal of which doesn't cause any errors, and specialization, which is apparently needed for conflicting implementations of the Slice trait.

I created a PR for Pear to remove all feature gates, though doing so appears require some mild lifetime changes in &str parameters.

As of today the beta compiles all code except for https://github.com/SergioBenitez/Pear/blob/master/codegen/src/parser.rs#L168 . https://doc.rust-lang.org/proc_macro/struct.Span.html#method.join is nightly only and in all other compilers returns None.

Open issue for Span.join is https://github.com/rust-lang/rust/issues/54725

https://github.com/SergioBenitez/Pear/pull/27

July 16th seems to be the day for stable, and June 4th is the day for beta.

Is that planning still accurate? Excited to see Rocket on stable :)

Yes, Rocket itself should be able to compile on stable in two days. I'm not sure of the dependencies are all able to be built on beta currently, though.

Pear was the last using Nightly features AFAICT from the discussion above and the linked issues & PRs, and that was fixed today in https://github.com/SergioBenitez/Pear/commit/333c9bf5e2c516c23b17c7482b410f1448c1b3af. The only thing that remains to do for Rocket to compile on the current beta / upcoming stable is Pear being updated.

Stable is out now apparently, so it should compile on 1.45.x and later

That's great to see @npmccallum, thanks for the heads up. I just tried building a Rocket project with the new stable Rust 1.45.0 and the build still failed around this issue, that's what brought me here. Hopefully all that's needed at this point for this use case is a release for Pear with that merged work and then updated references to the new Pear crate version in this repo. Looking forward to that!

Thank you, everyone, sincerely. :heart:

Congratulations Sergio!

rocket

That's one small step for a crate; one giant leap for Rustaceans

Goodbye Issue #19 Hello Stable! 🍾🍾🍾

Big thank you and congrats!!!

I've been waiting for this eagerly over the last few days. Kept on refreshing my browser tabs. Finally!

Congrats. Will there be a 0.4.x release for this or will we have to wait for 0.5?

Congrats. This is awesome news. Great work!

Congratulations! Don't forget to update doc

Congrats. Will there be a 0.4.x release for this or will we have to wait for 0.5?

It will happen in 0.5. Several of the features used by 0.4 (e.g. try_trait, specialization) are part of public API and won't be removed.

Congratulations! Don't forget to update doc

And crates.io front-page as well

Congratulations! πŸš€

The getting started page still haven't been updated yet. πŸš€πŸš€πŸš€

The current latest stable Rocket is 0.4, which still needs nightly Rust. So those updates will likely have to wait for Rocket 0.5.

i can't wait for v0.5 to start experimenting. i might write a v2 app at work in rust and rocket :) now it's a monolithic-like project written in php and new features feels too much for php (e.g. no multithreading in php, slow for algorithms)

Is there an estimated timeline for 0.5 to be released?

@DanielPower , as soon as it is done, unless things planned for the 0.5.0 milestone turn out to be to hard to do now, then possibly sooner (by not including them)

Why stable is not priority? No one wants to use rocket in production?

Why patience is not priority? The nightly is running quite stable in production here πŸ™‚

Why patience is not priority? The nightly is running quite stable in production here πŸ™‚

This not makes sense. The proper name says "nightly".

An IT system doesn't become "production ready" just because it has the name stable, nor does it become non-prod ready just because some component has "nightly" in its version string somewhere.

Inquiring about "when something will be done" or "why it's not done already" in a free & open source project will almost always result in someone (in this instance it's me) responding with "when someone does it" or "patches welcome".

This is only a hispster project XD. Just for fun. I was wrong.

@jcbritobr, in the chat people are talking about the next release that is coming soon. So if we are a little bit patient, everything is fine.

This is only a hispster project XD. Just for fun. I was wrong.

Chill @jcbritobr, there is no need to be [passive-]aggressive here, dude.

I understand you might be confused by the naming of the toolchains (stable vs nightly). I acknowledge they are indeed misleading.

Feel free to check the Rust release process at https://forge.rust-lang.org/release/process.html

Nightly indeed comes from the master branch and it may introduce regressions (and it sporadically does), but the nightly "instability" is not about this. Stability is about the APIs, not about the compiler introducing bugs or breaking someone's code.

If your application compiles in a specific nightly version, there should not be any problem just because it is nightly. As long as it compiles, in general, you should be safe.

β€” Oh, but if it runs on nightly, my build will not be reproducible and it will change every day, oh noes!

Yeah, nightly itself will change, but it is completely possible to pin a specific nightly version, e.g., 2020-11-30's nightly version! There is no need to be afraid of your toolchain changing without you knowing.

Finally, I am aware of a multitude of projects running Rocket in production. Using nightly does not make a project unstable, nor not-production-ready nor hipster as you said.

Feel free to reach out via the chat or other means if you require further clarification :)

P.S.: I am not aware of any of the contributors being paid to develop Rocket, so it is rough to impose priorities

@jcbritobr, in the chat people are talking about the next release that is coming soon. So if we are a little bit patient, everything is fine.

Hello. I'm not being passive/agressive. Look up these answers above. I only think bugs and stability comes first of new features. Postpone rocket on stable rust doesn't seems to be an intelligent decision. Nightly rust isn't stable rust, but if you guys think so very well. For me, its a hispter atitude. Just like for fun. Nothing to really help or agreggate the project.

@jcbritobr the latest version of Rocket is already using Stable Rust! This is done already, that's why this issue is Closed, you are knocking on open doors. We are just waiting for the next Rocket release (0.5), because this is a breaking change.
It will be done shortly, the release depends on a couple more stuff though, compiling on Stable is just ONE of the new features, the list of the in-progress things can be found here:
https://github.com/SergioBenitez/Rocket/issues?q=is%3Aopen+is%3Aissue+milestone%3A0.5.0

Also there's another question about the expected time of the release here: https://github.com/SergioBenitez/Rocket/issues/1476
As you can see SergioBenitez commented in November that he expects an RC for 0.5 to be released by the end of the month. It's only the 1st of December, so I think we can all be a little more patient with this.

In the meantime you can use Rocket from the master branch with Stable Rust. Or maybe help with one of the ongoing issues in the Milestones section to make the release happen faster.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Hokutosei picture Hokutosei  Β·  4Comments

Perseus101 picture Perseus101  Β·  4Comments

loothood picture loothood  Β·  4Comments

lucklove picture lucklove  Β·  4Comments

marceloboeira picture marceloboeira  Β·  3Comments