Skip to content

Can't compile after updating to 0.7.11 from 0.7.5 #68

@Milerius

Description

@Milerius
error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2089:50
     |
2089 |                 let mut existing_history = match self.load_history_from_file(ctx).compat().await {
     |                                                  ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2094:47
     |
2094 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2107:64
     |
2107 |                 let total_amount = u256_to_big_decimal(amount, self.decimals).unwrap();
     |                                                                ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2114:33
     |
2114 |                 if from_addr == self.my_address {
     |                                 ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2118:31
     |
2118 |                 if to_addr == self.my_address {
     |                               ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2123:31
     |
2123 |                     "coin" => self.ticker.clone(), "client" => "ethereum", "method" => "tx_detail_by_hash");
     |                               ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2125:37
     |
2125 |                 let web3_tx = match self
     |                                     ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2136:47
     |
2136 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2148:31
     |
2148 |                     "coin" => self.ticker.clone(), "client" => "ethereum", "method" => "tx_detail_by_hash");
     |                               ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2155:47
     |
2155 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2162:37
     |
2162 |                 let receipt = match self
     |                                     ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2173:47
     |
2173 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2183:39
     |
2183 |                 let fee_coin = match &self.coin_type {
     |                                       ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2184:41
     |
2184 |                     EthCoinType::Eth => self.ticker(),
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2195:35
     |
2195 |                 let block = match self
     |                                   ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2206:47
     |
2206 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2214:47
     |
2214 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2229:27
     |
2229 |                     coin: self.ticker.clone(),
     |                           ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2249:33
     |
2249 |                 if let Err(e) = self.save_history_to_file(ctx, existing_history).compat().await {
     |                                 ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2252:43
     |
2252 |                         &[&"tx_history", &self.ticker],
     |                                           ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2481:83
     |
2481 |                 mm_counter!(ctx.metrics, "tx.history.request.count", 1, "coin" => self.ticker.clone(), "method" => "tx_detail_by_hash");
     |                                                                                   ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2483:37
     |
2483 |                 let web3_tx = match self
     |                                     ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2494:47
     |
2494 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2509:47
     |
2509 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2516:84
     |
2516 |                 mm_counter!(ctx.metrics, "tx.history.response.count", 1, "coin" => self.ticker.clone(), "method" => "tx_detail_by_hash");
     |                                                                                    ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2518:37
     |
2518 |                 let receipt = match self
     |                                     ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2529:47
     |
2529 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2539:39
     |
2539 |                 let fee_coin = match &self.coin_type {
     |                                       ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2540:41
     |
2540 |                     EthCoinType::Eth => self.ticker(),
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2555:38
     |
2555 |                 if call_data.from == self.my_address {
     |                                      ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2565:36
     |
2565 |                 if call_data.to == self.my_address {
     |                                    ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2573:35
     |
2573 |                 let block = match self
     |                                   ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2584:47
     |
2584 | ...                   &[&"tx_history", &self.ticker],
     |                                         ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2598:27
     |
2598 |                     coin: self.ticker.clone(),
     |                           ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2619:33
     |
2619 |                 if let Err(e) = self.save_history_to_file(ctx, existing_history.clone()).compat().await {
     |                                 ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0434]: can't capture dynamic environment in a fn item
    --> mm2src/coins/eth.rs:2622:43
     |
2622 |                         &[&"tx_history", &self.ticker],
     |                                           ^^^^
     |
     = help: use the `|| { ... }` closure form instead

error[E0698]: type inside `async fn` body must be known in this context
    --> mm2src/coins/eth.rs:1964:76
     |
1964 |                         BlockNumber::Number((saved_events.earliest_block - 1).into()),
     |                                                                            ^ cannot infer type for type `{integer}`
     |
note: the type is part of the `async fn` body because of this `await`
    --> mm2src/coins/eth.rs:1977:25
     |
1977 |                         Timer::sleep(10.).await;
     |                         ^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async fn` body must be known in this context
    --> mm2src/coins/eth.rs:1988:76
     |
1988 |                         BlockNumber::Number((saved_events.earliest_block - 1).into()),
     |                                                                            ^ cannot infer type for type `{integer}`
     |
note: the type is part of the `async fn` body because of this `await`
    --> mm2src/coins/eth.rs:2001:25
     |
2001 |                         Timer::sleep(10.).await;
     |                         ^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async fn` body must be known in this context
    --> mm2src/coins/eth.rs:2026:74
     |
2026 |                         BlockNumber::Number((saved_events.latest_block + 1).into()),
     |                                                                          ^ cannot infer type for type `{integer}`
     |
note: the type is part of the `async fn` body because of this `await`
    --> mm2src/coins/eth.rs:2040:25
     |
2040 |                         Timer::sleep(10.).await;
     |                         ^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async fn` body must be known in this context
    --> mm2src/coins/eth.rs:2050:74
     |
2050 |                         BlockNumber::Number((saved_events.latest_block + 1).into()),
     |                                                                          ^ cannot infer type for type `{integer}`
     |
note: the type is part of the `async fn` body because of this `await`
    --> mm2src/coins/eth.rs:2064:25
     |
2064 |                         Timer::sleep(10.).await;
     |                         ^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async fn` body must be known in this context
    --> mm2src/coins/eth.rs:2414:74
     |
2414 |                         BlockNumber::Number((saved_traces.latest_block + 1).into()),
     |                                                                          ^ cannot infer type for type `{integer}`
     |
note: the type is part of the `async fn` body because of this `await`
    --> mm2src/coins/eth.rs:2428:25
     |
2428 |                         Timer::sleep(10.).await;
     |                         ^^^^^^^^^^^^^^^^^^^^^^^

error[E0698]: type inside `async fn` body must be known in this context
    --> mm2src/coins/eth.rs:2437:74
     |
2437 |                         BlockNumber::Number((saved_traces.latest_block + 1).into()),
     |                                                                          ^ cannot infer type for type `{integer}`
     |
note: the type is part of the `async fn` body because of this `await`
    --> mm2src/coins/eth.rs:2451:25
     |
2451 |                         Timer::sleep(10.).await;
     |                         ^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 42 previous errors

Some errors have detailed explanations: E0434, E0698.
For more information about an error, try `rustc --explain E0434`.
error: could not compile `coins`

To learn more, run the command again with --verbose.

The new version seems to break every existing implementation - furthermore, it's force user to change existing code to suits the mockable behaviour, this is wrong IMHO.

code change: Capture d’écran 2021-10-18 à 14 16 01

(If I move those 2 function into another impl block that doesn't have the macros mockable that make everything compile, but I thought you would like to know that for some complex block there is some problem)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions