Skip to content

cannot borrow *self as immutable #561

Closed

Description

@est31

Hi, as I'm seeing Rust developers getting serious about enabling the new borrow checker on the 2015 edition (rust-lang/rust#57804 / rust-lang/rust#59114), I compiled my local project with RUSTFLAGS="-Zborrowck=migrate -Ztwo-phase-borrows" cargo +nightly check to test for any possible future problems.

When it compiled nalgebra 0.16.13 for me, I got multiple newly introduced compiler warnings. Even on nalgebra master, I'm getting one compiler warning:

warning[E0502]: cannot borrow `*self` as immutable because it is also borrowed as mutable
   --> src/base/cg.rs:297:44
    |
297 |                 self[(j, i)] += shift[j] * self[(D::dim() - 1, i)];
    |                 ---------------------------^^^^-------------------
    |                 |                          |
    |                 |                          immutable borrow occurs here
    |                 mutable borrow occurs here
    |                 mutable borrow later used here
    |
    = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
    = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future

I'd love a fix of the issue and a new crates.io release soon after that. Thanks!

Activity

  1. added a commit that references this issue on Mar 12, 2019
    db3d08f
  2. est31 commented on Mar 12, 2019

    @est31
    ContributorAuthor

    @matthewjasper is this behaviour intended? Is it a legitimate error of the nalgebra crate?

  3. sebcrozet commented on Mar 12, 2019

    @sebcrozet
    Member

    Hi! Thank you for reporting this and for the fix. I find this warning strange, so I prefer to wait for what @matthewjasper has to say about it before merging anything.

    Also keep in mind we don't intend to support rust 2015 indefinitely so at some point in the future rust 2018 will likely be necessary for using nalgebra (e.g. whenever specialization and const-generics land).

  4. matthewjasper commented on Mar 12, 2019

    @matthewjasper

    Yes, this is intended. It's the result of fixing rust-lang/rust#27868 .

  5. est31 commented on Mar 13, 2019

    @est31
    ContributorAuthor

    Yeah, so I guess I'd ask my PR to get merged then.

  6. est31 commented on Mar 13, 2019

    @est31
    ContributorAuthor

    This might already arrive in nightlies in next week. The sooner a fixed version is available on crates.io, the better.

  7. added a commit that references this issue on Sep 3, 2020
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions