Skip to content
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

wasm: fix make wasm build failed by error[E0521]: borrowed data escapes outside of closure #4825

Merged
merged 2 commits into from
Mar 5, 2025

Conversation

eval-exec
Copy link
Collaborator

What problem does this PR solve?

This PR want to fix: make wasn error on latest develop branch:

error[E0521]: borrowed data escapes outside of closure
  --> network/src/services/dump_peer_store.rs:43:24
   |
42 |         self.network_state.with_peer_store_mut(|peer_store| {
   |                                                 ----------
   |                                                 |
   |                                                 `peer_store` is a reference that is only valid in the closure body
   |                                                 has type `&'1 mut PeerStore`
43 |             let task = peer_store.dump_to_idb(path);
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                        |
   |                        `peer_store` escapes the closure body here
   |                        argument requires that `'1` must outlive `'static`

What is changed and how it works?

Related changes

  • change dump_to_idb from a method to a function, remove &self param

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code ci-runs-only: [ quick_checks,linters ]

Side effects

  • None

Release note

Title Only: Include only the PR title in the release note.

@eval-exec eval-exec requested a review from a team as a code owner March 5, 2025 05:34
@eval-exec eval-exec requested review from quake and driftluo and removed request for a team March 5, 2025 05:34
@eval-exec eval-exec marked this pull request as draft March 5, 2025 05:34
@driftluo
Copy link
Collaborator

driftluo commented Mar 5, 2025

lifetime capture is changed, use use<> to avoid impl Future lifetime bind with self
https://doc.rust-lang.org/edition-guide/rust-2024/rpit-lifetime-capture.html

@eval-exec eval-exec marked this pull request as ready for review March 5, 2025 06:12
@eval-exec eval-exec requested a review from zhangsoledad March 5, 2025 07:08
@eval-exec eval-exec added this pull request to the merge queue Mar 5, 2025
Merged via the queue into nervosnetwork:develop with commit 0554738 Mar 5, 2025
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants