[GH-ISSUE #231] Borrow checker not happy about TrackId reference. #1052

Closed
opened 2026-03-14 13:14:28 +03:00 by kerem · 3 comments
Owner

Originally created by @nuugen on GitHub (Aug 5, 2023).
Original GitHub issue: https://github.com/aome510/spotify-player/issues/231

Describe the bug
Code is not passing borrow checker after the latest commit implementing playlist-related CLI commands. Specifically, the reference to the TrackId is pushed to the a buffer that outlives the lifetime of the allocated data in deleted_hash_set.

To Reproduce
Run cargo check in project root.

Expected behavior
No borrow checking error.

Log and backtrace

? cargo check                                                                                                                   
    Checking spotify_player v0.14.1 (/Users/hoanglinh.nguyen/repos/public/spotify-player/spotify_player)
error[E0597]: `deleted_hash_set` does not live long enough
   --> spotify_player/src/cli/client.rs:601:22
    |
601 |             for t in &deleted_hash_set {
    |                      ^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
631 |     }
    |     - `deleted_hash_set` dropped here while still borrowed
...
635 |     track_buff = Vec::new();
    |     ---------- borrow might be used here, when `track_buff` is dropped and runs the `Drop` code for type `Vec`
    |
    = note: values in a scope are dropped in the opposite order they are defined

For more information about this error, try `rustc --explain E0597`.
error: could not compile `spotify_player` due to previous error

Environment

  • OS: OSX Ventura 13.5
  • Application version: e8cfab9dc923f6e293669d92a6e2fb5f17f10d40
  • Application features: if applicable, provide cargo features used to build spotify_player
Originally created by @nuugen on GitHub (Aug 5, 2023). Original GitHub issue: https://github.com/aome510/spotify-player/issues/231 **Describe the bug** Code is not passing borrow checker after the latest commit implementing playlist-related CLI commands. Specifically, the reference to the `TrackId` is pushed to the a buffer that outlives the lifetime of the allocated data in `deleted_hash_set`. **To Reproduce** Run `cargo check` in project root. **Expected behavior** No borrow checking error. **Log and backtrace** ```bash ? cargo check Checking spotify_player v0.14.1 (/Users/hoanglinh.nguyen/repos/public/spotify-player/spotify_player) error[E0597]: `deleted_hash_set` does not live long enough --> spotify_player/src/cli/client.rs:601:22 | 601 | for t in &deleted_hash_set { | ^^^^^^^^^^^^^^^^^ borrowed value does not live long enough ... 631 | } | - `deleted_hash_set` dropped here while still borrowed ... 635 | track_buff = Vec::new(); | ---------- borrow might be used here, when `track_buff` is dropped and runs the `Drop` code for type `Vec` | = note: values in a scope are dropped in the opposite order they are defined For more information about this error, try `rustc --explain E0597`. error: could not compile `spotify_player` due to previous error ``` **Environment** - OS: OSX Ventura 13.5 - Application version: `e8cfab9dc923f6e293669d92a6e2fb5f17f10d40` - Application features: if applicable, provide [cargo features](https://doc.rust-lang.org/cargo/reference/features.html) used to build `spotify_player`
kerem 2026-03-14 13:14:28 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@aome510 commented on GitHub (Aug 5, 2023):

Interesting, I didn’t see any issues when building the code. CIs also look fine.

Will check again later td.

cc @justjokiing. Maybe you can double check

<!-- gh-comment-id:1666555106 --> @aome510 commented on GitHub (Aug 5, 2023): Interesting, I didn’t see any issues when building the code. CIs also look fine. Will check again later td. cc @justjokiing. Maybe you can double check
Author
Owner

@aome510 commented on GitHub (Aug 5, 2023):

Are you using the latest Rust?

<!-- gh-comment-id:1666555332 --> @aome510 commented on GitHub (Aug 5, 2023): Are you using the latest Rust?
Author
Owner

@nuugen commented on GitHub (Aug 5, 2023):

Oh, that was the problem. After updating from my outdated Rust from March, it was happy again!

Thanks!

<!-- gh-comment-id:1666562591 --> @nuugen commented on GitHub (Aug 5, 2023): Oh, that was the problem. After updating from my outdated Rust from March, it was happy again! Thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#1052
No description provided.