rust-lang / jobserver-rs

Apache License 2.0
69 stars 39 forks source link

Wasm Compile Target Broken in v0.1.30 #85

Closed jozanza closed 4 months ago

jozanza commented 4 months ago

It looks like the crate fails to compile with a wasm target because wasm::Client::try_acquire method improperly returns an Option<Acquired> rather than a Result<Option<Acquired>>. This is fixed by #84 .

For some additional context, the compiler error output looks like this on my machine:

   Compiling jobserver v0.1.30
error[E0308]: mismatched types
  --> /path/to/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jobserver-0.1.30/src/wasm.rs:51:13
   |
48 |     pub fn try_acquire(&self) -> io::Result<Option<Acquired>> {
   |                                  ---------------------------- expected `Result<Option<imp::Acquired>, std::io::Error>` because of return type
...
51 |             None
   |             ^^^^ expected `Result<Option<...>, ...>`, found `Option<_>`
   |
   = note: expected enum `Result<Option<imp::Acquired>, std::io::Error>`
              found enum `Option<_>`
help: try wrapping the expression in `Ok`
   |
51 |             Ok(None)
   |             +++    +

error[E0308]: mismatched types
   --> /path/to/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jobserver-0.1.30/src/wasm.rs:54:16
    |
54  |             Ok(Acquired(()))
    |             -- ^^^^^^^^^^^^ expected `Option<Acquired>`, found `Acquired`
    |             |
    |             arguments to this enum variant are incorrect
    |
    = note: expected enum `Option<imp::Acquired>`
             found struct `imp::Acquired`
help: the type constructed contains `imp::Acquired` due to the type of the argument passed
   --> /path/to/.cargo/registry/src/index.crates.io-6f17d22bba15001f/jobserver-0.1.30/src/wasm.rs:54:13
    |
54  |             Ok(Acquired(()))
    |             ^^^------------^
    |                |
    |                this argument influences the type of `Ok`
note: tuple variant defined here
   --> /path/to/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:506:5
    |
506 |     Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^
help: try wrapping the expression in `Some`
    |
54  |             Ok(Some(Acquired(())))
    |                +++++            +