iron / router

Router middleware for the Iron web framework.
165 stars 74 forks source link

Fails to compile with current latest Iron (0.6.0) #142

Closed davechallis closed 6 years ago

davechallis commented 6 years ago

Trying to compile this router example currently fails with the latest Iron release (0.6.0).

Tested with a new project containing the above code, and Cargo.toml containing:

iron = "*"
router = "*"

This give the following compiler errors:

error[E0281]: type mismatch: `fn(&mut iron::Request<'_, '_>) -> std::result::Result<iron::Response, iron::IronError> {main::handler}` implements the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>`, but the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::request::Request<'r, 'r>,)>` is required
  --> src/main.rs:10:12
   |
10 |     router.get("/", handler, "index");        // let router = router!(index: get "/" => handler,
   |            ^^^ expected struct `iron::request::Request`, found struct `iron::Request`
   |
   = note: required because of the requirements on the impl of `iron::middleware::Handler` for `fn(&mut iron::Request<'_, '_>) -> std::result::Result<iron::Response, iron::IronError> {main::handler}`

error[E0281]: type mismatch: `fn(&mut iron::Request<'_, '_>) -> std::result::Result<iron::Response, iron::IronError> {main::handler}` implements the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>`, but the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::request::Request<'r, 'r>,)>` is required
  --> src/main.rs:11:12
   |
11 |     router.get("/:query", handler, "query");  //                      query: get "/:query" => handler);
   |            ^^^ expected struct `iron::request::Request`, found struct `iron::Request`
   |
   = note: required because of the requirements on the impl of `iron::middleware::Handler` for `fn(&mut iron::Request<'_, '_>) -> std::result::Result<iron::Response, iron::IronError> {main::handler}`

error[E0277]: the trait bound `for<'r, 'r, 'r> router::Router: std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>` is not satisfied
  --> src/main.rs:13:5
   |
13 |     Iron::new(router).http("localhost:3000").unwrap();
   |     ^^^^^^^^^ the trait `for<'r, 'r, 'r> std::ops::Fn<(&'r mut iron::Request<'r, 'r>,)>` is not implemented for `router::Router`
   |
   = note: required because of the requirements on the impl of `iron::Handler` for `router::Router`
   = note: required by `<iron::Iron<H>>::new`

error[E0599]: no method named `http` found for type `iron::Iron<router::Router>` in the current scope
  --> src/main.rs:13:23
   |
13 |     Iron::new(router).http("localhost:3000").unwrap();
   |                       ^^^^
   |
   = note: the method `http` exists but the following trait bounds were not satisfied:
           `router::Router : iron::Handler`

error: aborting due to 4 previous errors
ernestas-poskus commented 6 years ago

Lock to 0.5.0

iron = "0.5.0"
router = "0.5.0"

iron 0.6.0 is released while router 0.6.0 is not https://github.com/iron/router/pull/141 so, for now, lock to 0.5.0

davechallis commented 6 years ago

@ernestas-poskus thanks, if an update is already on the way, happy to close this.

untitaker commented 6 years ago

Done