Skip to content

Cannot compile docs.rs #884

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

Closed
jyn514 opened this issue Feb 1, 2020 · 3 comments · Fixed by #916
Closed

Cannot compile docs.rs #884

jyn514 opened this issue Feb 1, 2020 · 3 comments · Fixed by #916
Labels
C-bug Category: This is a bug.

Comments

@jyn514
Copy link
Member

jyn514 commented Feb 1, 2020

Not sure what's going on here, it works fine with cargo 1.42.0-nightly (9d32b7b01 2020-01-26), but using cg_cranelift breaks:

$ CHANNEL="release" ../rustc_codegen_cranelift/cargo.sh run
rustc_codegen_cranelift is build for rustc 1.42.0-nightly (cd1ef390e 2020-01-31) but the default rustc version is rustc 1.41.0 (5e1a79984 2020-01-27).
Using rustc 1.42.0-nightly (cd1ef390e 2020-01-31).
error[E0277]: expected a `std::ops::Fn<()>` closure, found `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>`
   --> src/web/mod.rs:113:44
    |
113 |         let shared_resources = Self::chain(&pool_factory, rustdoc::SharedResourceHandler);
    |                                            ^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>`
    |
    = help: the trait `std::ops::Fn<()>` is not implemented for `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>`
    = note: wrap the `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>` in a closure with no arguments: `|| { /* code */ }
    = note: required for the cast to the object type `dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync`

error[E0277]: expected a `std::ops::Fn<()>` closure, found `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>`
   --> src/web/mod.rs:114:40
    |
114 |         let router_chain = Self::chain(&pool_factory, routes.iron_router());
    |                                        ^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>`
    |
    = help: the trait `std::ops::Fn<()>` is not implemented for `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>`
    = note: wrap the `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>` in a closure with no arguments: `|| { /* code */ }
    = note: required for the cast to the object type `dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync`

error[E0277]: expected a `std::ops::Fn<()>` closure, found `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>`
   --> src/web/mod.rs:184:29
    |
184 |                 Self::chain(&self.pool_factory, err).handle(req)
    |                             ^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>`
    |
    = help: the trait `std::ops::Fn<()>` is not implemented for `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>`
    = note: wrap the `std::boxed::Box<(dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync + 'static)>` in a closure with no arguments: `|| { /* code */ }
    = note: required for the cast to the object type `dyn std::ops::Fn() -> web::pool::Pool + std::marker::Send + std::marker::Sync`
@bjorn3 bjorn3 added the C-bug Category: This is a bug. label Feb 1, 2020
@bjorn3
Copy link
Member

bjorn3 commented Feb 1, 2020

When removing the Box<dyn FnOnce(...)> impl to workaround the missing unsized locals support I also had to remove the Box<dyn Fn(...)> and Box<dyn FnMut(...)> impls. As Fn and FnMut require an FnOnce impl.

Replacing the marked & with &* should fix this, I think. I am going to try this now.

@bjorn3
Copy link
Member

bjorn3 commented Feb 1, 2020

It works with & replaced with &*. Because I don't have libmagic installed, linking failes though.

From 891db3f6f2dfdb5cfbab805931823afb7cc7b24a Mon Sep 17 00:00:00 2001
From: bjorn3 <[email protected]>
Date: Sat, 1 Feb 2020 17:02:37 +0100
Subject: [PATCH] Workaround missing Fn for Box<Fn> impl

---
 src/web/mod.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/web/mod.rs b/src/web/mod.rs
index 07190a9..0619530 100644
--- a/src/web/mod.rs
+++ b/src/web/mod.rs
@@ -110,8 +110,8 @@ impl CratesfyiHandler {
         let routes = routes::build_routes();
         let blacklisted_prefixes = routes.page_prefixes();
 
-        let shared_resources = Self::chain(&pool_factory, rustdoc::SharedResourceHandler);
-        let router_chain = Self::chain(&pool_factory, routes.iron_router());
+        let shared_resources = Self::chain(&*pool_factory, rustdoc::SharedResourceHandler);
+        let router_chain = Self::chain(&*pool_factory, routes.iron_router());
         let prefix = PathBuf::from(env::var("CRATESFYI_PREFIX").unwrap()).join("public_html");
         let static_handler = Static::new(prefix)
             .cache(Duration::from_secs(STATIC_FILE_CACHE_DURATION));
@@ -181,7 +181,7 @@ impl Handler for CratesfyiHandler {
                 }
 
 
-                Self::chain(&self.pool_factory, err).handle(req)
+                Self::chain(&*self.pool_factory, err).handle(req)
             })
     }
 }
-- 
2.21.0 (Apple Git-122)

@jyn514
Copy link
Member Author

jyn514 commented Feb 1, 2020

Yeah libmagic is a known issue on our end. Thanks for checking and congrats that it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants