rust-osdev / cargo-xbuild

Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc.
Apache License 2.0
260 stars 25 forks source link

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

Closed phil-opp closed 2 years ago

phil-opp commented 2 years ago

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: https://github.com/rust-lang/rust/commit/1b9daa69640970e7858b7c8e1c9f72c604985e11

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