0

I have set up a rust base project according to the Getting Started page of the rocket-framework:

  1. I added this line to my Cargo.toml: rocket = "0.4.10"

  2. My main.rs:

    #![feature(proc_macro_hygiene, decl_macro)]
    
    #[macro_use] extern crate rocket;
    
    #[get("/")]
    fn index() -> &'static str {
        "Hello, world!"
    }
    
    fn main() {
        rocket::ignite().mount("/", routes![index]).launch();
    }
    

When I try to run (or cargo build it) I get the following error:

   Compiling rocket v0.4.10 error[E0277]: the trait bound `(dyn handler::Handler + 'static): handler::Handler` is not satisfied    --> /Users/.../.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.4.10/src/rocket.rs:299:41
    | 299 |             let outcome = route.handler.handle(request, data);
    |                                         ^^^^^^ the trait `handler::Handler` is not implemented for `(dyn handler::Handler + 'static)`

For more information about this error, try `rustc --explain E0277`. error: could not compile `rocket` due to previous error

I also tried it with previous versions of the rocket framework, all of them threw the same error.

Of course I'm using the latest nightly version of rust, right before cargo build I entered following commands:

rustup override set nightly
info: using existing install for 'nightly-x86_64-apple-darwin'
info: override toolchain for '/Users/...' set to 'nightly-x86_64-apple-darwin'

  nightly-x86_64-apple-darwin unchanged - rustc 1.58.0-nightly (bd41e09da 2021-10-18)

Is there a known issue with the latest rust compiler on MacOS? Is there any other solution I could try?

Sven Marnach
  • 574,206
  • 118
  • 941
  • 841
Piwo
  • 1,347
  • 1
  • 12
  • 19
  • 2
    This seems to be a bug in Nightly. Try installing a slightly older version – `rustup install nightly-2021-10-07` worked for me. – Sven Marnach Oct 20 '21 at 11:22
  • 1
    Alternatively use stable toolchain and rocket 0.5 release candidate – Ivan C Oct 20 '21 at 11:27
  • Reverting to a previous nightly-version actually did work and solved this problem. – Piwo Oct 20 '21 at 11:43
  • Here's the corresponding bug: https://github.com/rust-lang/rust/issues/89935 This should be fixed in tomorrow's nightly release. – Sven Marnach Oct 20 '21 at 18:18

0 Answers0