pact-foundation / pact-reference

Reference implementations for the pact specifications
https://pact.io
MIT License
91 stars 46 forks source link

Rust pact_consumer v0.10.x compilation error: mismatched types #277

Closed luca-iachini closed 1 year ago

luca-iachini commented 1 year ago

Hello, I am trying to set up pact_consumer for a demo project. By just importing the pact_consumer dependency:

[dev-dependencies]
pact_consumer = "=0.10.8"
reqwest = "0.11.18"
tokio = "1.28.1"

I get the following error:

error[E0308]: mismatched types
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1676:47
     |
1676 |   let plugin_data = setup_plugin_config(pact, &expected.boxed());
     |                     -------------------       ^^^^^^^^^^^^^^^^^ expected trait `pact_models::interaction::Interaction + Send + Sync`, found trait `pact_models::interaction::Interaction + Send + Sync + RefUnwindSafe`
     |                     |
     |                     arguments to this function are incorrect
     |
     = note: expected reference `&Box<(dyn pact_models::interaction::Interaction + Send + Sync + 'static)>`
                found reference `&Box<(dyn pact_models::interaction::Interaction + Send + Sync + RefUnwindSafe + 'static)>`
note: function defined here
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1490:4
     |
1490 | fn setup_plugin_config<'a>(
     |    ^^^^^^^^^^^^^^^^^^^
1491 |   pact: &Box<dyn Pact + Send + Sync + 'a>,
1492 |   interaction: &Box<dyn Interaction + Send + Sync>
     |   ------------------------------------------------

error[E0308]: mismatched types
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1729:49
     |
1729 |     let plugin_data = setup_plugin_config(pact, &expected.boxed());
     |                       -------------------       ^^^^^^^^^^^^^^^^^ expected trait `pact_models::interaction::Interaction + Send + Sync`, found trait `pact_models::interaction::Interaction + Send + Sync + RefUnwindSafe`
     |                       |
     |                       arguments to this function are incorrect
     |
     = note: expected reference `&Box<(dyn pact_models::interaction::Interaction + Send + Sync + 'static)>`
                found reference `&Box<(dyn pact_models::interaction::Interaction + Send + Sync + RefUnwindSafe + 'static)>`
note: function defined here
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1490:4
     |
1490 | fn setup_plugin_config<'a>(
     |    ^^^^^^^^^^^^^^^^^^^
1491 |   pact: &Box<dyn Pact + Send + Sync + 'a>,
1492 |   interaction: &Box<dyn Interaction + Send + Sync>
     |   ------------------------------------------------

error[E0308]: mismatched types
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1890:59
     |
1890 |     Ok(match_response(expected_response, response, &pact, &expected).await)
     |        --------------                                     ^^^^^^^^^ expected trait `pact_models::interaction::Interaction + Send + Sync`, found trait `pact_models::interHello,
I am trying to setup pact_consumer for a demo project. By just importing the pact_consumer dependency:action::Interaction + Send + Sync + RefUnwindSafe`
     |        |
     |        arguments to this function are incorrect
     |
     = note: expected reference `&Box<(dyn pact_models::interaction::Interaction + Send + Sync + 'static)>`
                found reference `&Box<dyn pact_models::interaction::Interaction + Send + Sync + RefUnwindSafe>`
note: function defined here
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1455:14
     |
1455 | pub async fn match_response<'a>(
     |              ^^^^^^^^^^^^^^
...
1459 |   interaction: &Box<dyn Interaction + Send + Sync>
     |   ------------------------------------------------

error[E0308]: mismatched types
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1909:74
     |
1909 |     let request_result = match_request(expected_request, request, &pact, &expected).await;
     |                          -------------                                   ^^^^^^^^^ expected trait `pact_models::interaction::Interaction + Send + Sync`, found trait `pact_models::interaction::Interaction + Send + Sync + RefUnwindSafe`
     |                          |
     |                          arguments to this function are incorrect
     |
     = note: expected reference `&Box<(dyn pact_models::interaction::Interaction + Send + Sync + 'static)>`
                found reference `&Box<dyn pact_models::interaction::Interaction + Send + Sync + RefUnwindSafe>`
note: function defined here
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1393:14
     |
1393 | pub async fn match_request<'a>(
     |              ^^^^^^^^^^^^^
...
1397 |   interaction: &Box<dyn Interaction + Send + Sync>
     |   ------------------------------------------------

error[E0308]: mismatched types
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1912:78
     |
1912 |     let response_result = match_response(expected_response, response, &pact, &expected).await;
     |                           --------------                                     ^^^^^^^^^ expected trait `pact_models::interaction::Interaction + Send + Sync`, found trait `pact_models::interaction::Interaction + Send + Sync + RefUnwindSafe`
     |                           |
     |                           arguments to this function are incorrect
     |
     = note: expected reference `&Box<(dyn pact_models::interaction::Interaction + Send + Sync + 'static)>`
                found reference `&Box<dyn pact_models::interaction::Interaction + Send + Sync + RefUnwindSafe>`
note: function defined here
    --> /home/lucaiachini/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_matching-1.0.8/src/lib.rs:1455:14
     |
1455 | pub async fn match_response<'a>(
     |              ^^^^^^^^^^^^^^
...
1459 |   interaction: &Box<dyn Interaction + Send + Sync>
     |   ------------------------------------------------

For more information about this error, try `rustc --explain E0308`.
error: could not compile `pact_matching` due to 5 previous errors

I am getting the same error for all the "0.10.x" versions.

rholshausen commented 1 year ago

I'm going to be releasing a new version of pact_consumer soon, but you can try lock pact_models to 1.0.13

Marwes commented 1 year ago

Also seeing this on the 0.9 verifier cli (0.10 doesn't work either). Adding RefUnwindSafe in https://github.com/pact-foundation/pact-reference/commit/261ecf472d468c881c7957fc5b06ad26648e09c3#diff-8e428ff90fe42b124abfa1fcbb60ab275565e95ee0e6a523019c06f083ddc4ae was not a semver compatible change as it affects the public API between crates, causing compilation errors when a crate before the change tries to pull in one with the change.

Running cargo install --locked works around the problem for now.

mefellows commented 1 year ago

Is this fixed now that a new release has gone out?

rholshausen commented 1 year ago

Yes, the dependencies should be correct now.

mefellows commented 1 year ago

Thanks. @Marwes please let us know if there are any issues, I'll close it off for now.