Skip to content

Conversation

@KarlHeitmann
Copy link
Owner

@KarlHeitmann KarlHeitmann commented Mar 22, 2023

This causes the following error message:

image

   Compiling git_explorer v0.1.0 (/home/karl/github/KarlHeitmann/rust/git_explorer)
warning: unused import: `Oid`
 --> src/ui/mod.rs:1:24
  |
1 | use git2::{Repository, Oid};
  |                        ^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0502]: cannot borrow `*self` as mutable because it is also borrowed as immutable
   --> src/explorer/mod.rs:171:17
    |
171 |                 self.paint_commit_track(self.repo.head().unwrap().peel_to_commit().unwrap(), branches)
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^-------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                 |                       |
    |                 |                       immutable borrow occurs here
    |                 |                       a temporary with access to the immutable borrow is created here ...
    |                 mutable borrow occurs here
172 |             }
    |             - ... and the immutable borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `git2::Reference`
    |
    = note: the temporary is part of an expression at the end of a block;
            consider forcing this temporary to be dropped sooner, before the block's local variables are dropped
help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block
    |
171 |                 let x = self.paint_commit_track(self.repo.head().unwrap().peel_to_commit().unwrap(), branches); x
    |                 +++++++                                                                                       +++

For more information about this error, try `rustc --explain E0502`.
warning: `git_explorer` (bin "git_explorer") generated 1 warning
error: could not compile `git_explorer` due to previous error; 1 warning emitted

@KarlHeitmann KarlHeitmann changed the title Minimum changes to reproduce the main error on PR #3 and PR #5 Minimum changes to reproduce the main error on PR #3 and PR #5 addressing issue #2 Mar 22, 2023
@KarlHeitmann KarlHeitmann added the help wanted Extra attention is needed label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant