Osspial / derin

A Derive-Based GUI Library for Rust
Mozilla Public License 2.0
19 stars 2 forks source link

Fails to compile #10

Closed jcmnn closed 6 years ago

jcmnn commented 6 years ago

rustc version: 1.30.0-nightly

The borrow checker is complaining about borrowing top_widget because it is also borrowed as mutable. It fails in three spots:

Log:

error[E0502]: cannot borrow `top_widget` as immutable because it is also borrowed as mutable
    Building [======================================================>  ] 87/90:                                                                                    --> derin_core\src\widget_stack\mod.rs:323:64
    Building [======================================================>  ] 87/90:                                                                                     |
    Building [======================================================>  ] 87/90:                                                                                 321 |                 match top_widget.as_parent_mut() {
    Building [======================================================>  ] 87/90:                                                                                     |                       ---------- mutable borrow occurs here
    Building [======================================================>  ] 87/90:                                                                                 322 |                     None => {
    Building [======================================================>  ] 87/90:                                                                                 323 |                         let widget_tags = ChildEventRecv::from(top_widget.widget_tag());
    Building [======================================================>  ] 87/90:                                                                                     |                                                                ^^^^^^^^^^ immutable borrow occurs here
    Building [======================================================>  ] 87/90:                                                                                 
    Building [======================================================>  ] 87/90:                                                                                 error[E0499]: cannot borrow `*top_widget` as mutable more than once at a time
    Building [======================================================>  ] 87/90:                                                                                    --> derin_core\src\widget_stack\mod.rs:327:37
    Building [======================================================>  ] 87/90:                                                                                     |
    Building [======================================================>  ] 87/90:                                                                                 321 |                 match top_widget.as_parent_mut() {
    Building [======================================================>  ] 87/90:                                                                                     |                       ---------- first mutable borrow occurs here
    Building [======================================================>  ] 87/90:                                                                                 ...
    Building [======================================================>  ] 87/90:                                                                                 327 |                                     top_widget,
    Building [======================================================>  ] 87/90:                                                                                     |                                     ^^^^^^^^^^ second mutable borrow occurs here
    Building [======================================================>  ] 87/90:                                                                                 
    Building [======================================================>  ] 87/90:                                                                                 error[E0502]: cannot borrow `top_widget` as immutable because it is also borrowed as mutable
    Building [======================================================>  ] 87/90:                                                                                    --> derin_core\src\widget_stack\mod.rs:334:46
    Building [======================================================>  ] 87/90:                                                                                     |
    Building [======================================================>  ] 87/90:                                                                                 321 |                 match top_widget.as_parent_mut() {
    Building [======================================================>  ] 87/90:                                                                                     |                       ---------- mutable borrow occurs here
    Building [======================================================>  ] 87/90:                                                                                 ...
    Building [======================================================>  ] 87/90:                                                                                 334 |                             let widget_tag = top_widget.widget_tag();
    Building [======================================================>  ] 87/90:                                                                                     |                                              ^^^^^^^^^^ immutable borrow occurs here
Osspial commented 6 years ago

This is happening because some of the code depends on NLL behaviors that were removed from the compiler earlier this year. I've had a code change in the works that could get rid of that behavior, but I've been focusing on other stuff and haven't been able to complete it.

However, if you want to build this the last version of the compiler it works on is nightly-2018-05-17. Give that a go and it should run fine.

jcmnn commented 6 years ago

Looking through the code, this is designed better than other non-web-based GUI libraries. Are you accepting contributions? I'm interesting in contributing and using it in one of my projects after this issue is fixed.

Osspial commented 6 years ago

I looked at the code and fixing this turned out to be fairly easy, so it should work on more recent compilers. As far as accepting contributions, sure! I'm currently working on a fairly big overhaul to the core event dispatch system though (on the revamped_elo branch), and I don't think I'll be looking at PRs until that's done since that'll break a lot of stuff.