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

cannot borrow *self as immutable #561

Closed
est31 opened this issue Mar 12, 2019 · 5 comments
Closed

cannot borrow *self as immutable #561

est31 opened this issue Mar 12, 2019 · 5 comments

Comments

@est31
Copy link
Contributor

est31 commented Mar 12, 2019

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!

est31 added a commit to est31/nalgebra that referenced this issue Mar 12, 2019
@est31
Copy link
Contributor Author

est31 commented Mar 12, 2019

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

@sebcrozet
Copy link
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).

@matthewjasper
Copy link

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

@est31
Copy link
Contributor Author

est31 commented Mar 13, 2019

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

@est31
Copy link
Contributor Author

est31 commented Mar 13, 2019

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

est31 added a commit to est31/mimas that referenced this issue Sep 3, 2020
This gets us a fix for a forward compat
compiler warning for the upcoming NLL enabling
on the 2015 edition.

See dimforge/nalgebra#561
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

No branches or pull requests

3 participants