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

Building alloc fails since nightly 2022-06-17 #104

Closed
phil-opp opened this issue Jun 21, 2022 · 0 comments · Fixed by #105
Closed

Building alloc fails since nightly 2022-06-17 #104

phil-opp opened this issue Jun 21, 2022 · 0 comments · Fixed by #105

Comments

@phil-opp
Copy link
Member

The following error occurs:

error[E0502]: cannot borrow `map.root` as mutable because it is also borrowed as immutable
   --> /home/philipp/.rustup/toolchains/bisector-ci-1b9daa69640970e7858b7c8e1c9f72c604985e11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/collections/btree/map.rs:295:25
    |
295 |         let root_node = map.root.get_or_insert_with(|| Root::new(&*map.alloc)).borrow_mut();
    |                         ^^^^^^^^^------------------^--^^^^^^^^^^^^^---------^^
    |                         |        |                  |              |
    |                         |        |                  |              first borrow occurs due to use of `map` in closure
    |                         |        |                  immutable borrow occurs here
    |                         |        immutable borrow later used by call
    |                         mutable borrow occurs here

error[E0502]: cannot borrow `self.root` as mutable because it is also borrowed as immutable
    --> /home/philipp/.rustup/toolchains/bisector-ci-1b9daa69640970e7858b7c8e1c9f72c604985e11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/collections/btree/map.rs:1112:20
     |
1112 |         let root = self.root.get_or_insert_with(|| Root::new(&*self.alloc));
     |                    ^^^^^^^^^^------------------^--^^^^^^^^^^^^^----------^^
     |                    |         |                  |              |
     |                    |         |                  |              first borrow occurs due to use of `self` in closure
     |                    |         |                  immutable borrow occurs here
     |                    |         immutable borrow later used by call
     |                    mutable borrow occurs here

The cargo bisect-rustc tool points to this commit: rust-lang/rust@1b9daa6

The error does not happen with cargo's own -Zbuild-std, so it must depend on the build command somehow.

phil-opp added a commit that referenced this issue Jun 21, 2022
The alloc library was switched to the 2021 edition in <rust-lang/rust#92068>. However, it did not use any features of the new edition until PR <rust-lang/rust#98103>, which relies on the newer closure capture mechanism. This commit fixes the build on the latest nightlies, which include that PR.

Fixes #104
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

Successfully merging a pull request may close this issue.

1 participant