Skip to content

error[E0502]: cannot borrow *image_buf as immutable because it is also borrowed as mutable #345

Description

@tolotrasamuel

Description

The source code is not building with the error:


error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
  --> crates/rendering/src/decoder/avassetreader.rs:34:41
   |
32 |                     let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
   |                                 --------- mutable borrow occurs here
33 |
34 |                     let bytes_per_row = image_buf.plane_bytes_per_row(0);
   |                                         ^^^^^^^^^ immutable borrow occurs here
...
57 |                 } else {
   |                 - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
  --> crates/rendering/src/decoder/avassetreader.rs:35:33
   |
32 |                     let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
   |                                 --------- mutable borrow occurs here
...
35 |                     let width = image_buf.width() as usize;
   |                                 ^^^^^^^^^ immutable borrow occurs here
...
57 |                 } else {
   |                 - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
  --> crates/rendering/src/decoder/avassetreader.rs:36:34
   |
32 |                     let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
   |                                 --------- mutable borrow occurs here
...
36 |                     let height = image_buf.height();
   |                                  ^^^^^^^^^ immutable borrow occurs here
...
57 |                 } else {
   |                 - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
  --> crates/rendering/src/decoder/avassetreader.rs:40:29
   |
32 |                     let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
   |                                 --------- mutable borrow occurs here
...
40 |                             image_buf.plane_base_address(0),
   |                             ^^^^^^^^^ immutable borrow occurs here
...
57 |                 } else {
   |                 - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
  --> crates/rendering/src/decoder/avassetreader.rs:68:47
   |
66 |                             let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
   |                                         --------- mutable borrow occurs here
67 |
68 |                             for plane_i in 0..image_buf.plane_count() {
   |                                               ^^^^^^^^^ immutable borrow occurs here
...
91 |                         }
   |                         - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
  --> crates/rendering/src/decoder/avassetreader.rs:69:53
   |
66 |                             let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
   |                                         --------- mutable borrow occurs here
...
69 |                                 let bytes_per_row = image_buf.plane_bytes_per_row(plane_i);
   |                                                     ^^^^^^^^^ immutable borrow occurs here
...
91 |                         }
   |                         - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
  --> crates/rendering/src/decoder/avassetreader.rs:70:46
   |
66 |                             let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
   |                                         --------- mutable borrow occurs here
...
70 |                                 let height = image_buf.plane_height(plane_i);
   |                                              ^^^^^^^^^ immutable borrow occurs here
...
91 |                         }
   |                         - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
  --> crates/rendering/src/decoder/avassetreader.rs:77:41
   |
66 |                             let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
   |                                         --------- mutable borrow occurs here
...
77 |                                         image_buf.plane_base_address(plane_i),
   |                                         ^^^^^^^^^ immutable borrow occurs here
...
91 |                         }
   |                         - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
   --> crates/rendering/src/decoder/avassetreader.rs:95:47
    |
93  |                             let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
    |                                         --------- mutable borrow occurs here
94  |
95  |                             for plane_i in 0..image_buf.plane_count() {
    |                                               ^^^^^^^^^ immutable borrow occurs here
...
118 |                         }
    |                         - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
   --> crates/rendering/src/decoder/avassetreader.rs:96:53
    |
93  |                             let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
    |                                         --------- mutable borrow occurs here
...
96  |                                 let bytes_per_row = image_buf.plane_bytes_per_row(plane_i);
    |                                                     ^^^^^^^^^ immutable borrow occurs here
...
118 |                         }
    |                         - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
   --> crates/rendering/src/decoder/avassetreader.rs:97:46
    |
93  |                             let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
    |                                         --------- mutable borrow occurs here
...
97  |                                 let height = image_buf.plane_height(plane_i);
    |                                              ^^^^^^^^^ immutable borrow occurs here
...
118 |                         }
    |                         - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

error[E0502]: cannot borrow `*image_buf` as immutable because it is also borrowed as mutable
   --> crates/rendering/src/decoder/avassetreader.rs:104:41
    |
93  |                             let _lock = image_buf.base_address_lock(LockFlags::READ_ONLY).unwrap();
    |                                         --------- mutable borrow occurs here
...
104 |                                         image_buf.plane_base_address(plane_i),
    |                                         ^^^^^^^^^ immutable borrow occurs here
...
118 |                         }
    |                         - mutable borrow might be used here, when `_lock` is dropped and runs the `Drop` code for type `BaseAddrLockGuard`

Reproduction

I ran all steps in the Contribution.md but once I reached pnpm dev:desktop I got the error

Additional Context

  • Cap version:
    name = "cap-desktop"
    version = "0.3.27"
  • Operating system, version:
    MacOS Sonoma 14.0
  • Device (optional):

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions