Change:
This code is the protocol handler, and generated by one of the MAVLink specification. It is C/Rust mixed project, so to compile it you will need Rust , CC an any C compiler. To check how slow rustc is, , and run cargo test in the GroundControl/demo dir Exactly this project is compiled with error, cause the borrow checker complains in one place. But anyway, the problem is that compilation is unacceptably slow. Description generated API is generated sample of using generated API the test I generate variation of this project, with same functionality, in C, C++, C#.... They are the compiled in seconds ! What wrong with my Rust project? How can I speed up compilation? My PC Intel I7-7700K RAM 32G SSD Samsung 970 PRO cargo -V cargo 1.39.0-nightly ( 2019-09-25) rustc -V rustc 1.40.0-nightly ( 2019-09-30)
Please provide build instructions for that code. Running in gives: .
But I wrote and run cargo test in the GroundControl/demo dir
That gives the same error, since it just has a dependency on the crate in ...
Small bug fix in the file. Please try again. Thanks.
That didn't fix it
on my debian and windows 10 build script shown: cargo:warning=Starting search config.h in.... cargo:warning=/root/InRUST/GroundControl/demo/target/debug/build/blackbox-sys-/out cargo:warning=/root/InRUST/GroundControl/demo/target/debug/build/blackbox-sys- cargo:warning=/root/InRUST/GroundControl/demo/target/debug/build cargo:warning=/root/InRUST/GroundControl/demo/target/debug cargo:warning=/root/InRUST/GroundControl/demo/target cargo:warning=/root/InRUST/GroundControl/demo cargo:warning=<<< Find and use generated config.h in root/InRUST/GroundControl/lib/src/
made more platform specific fixes. check now please.
I've looked into this code and likely found the problem. The bright side: it compiles in under half a minute if the errors are removed. The part of the code causing this problem is a test function that tries to test everything at once and has about 8000 lines. The function contains (as of commit ) 76 borrow checker errors and the part that takes 5 hours is generating the 3-point errors for them. The time is dominated by the for the function body.
A minimized reproduction looks like this On my laptop this code requires about 25 seconds to print the error for the 1000 statements generated above and scales with the cube of the statement count.
On the bright side, waiting 5 hours for borrowck errors is still faster than trying to debug a memory corruption in a language without borrowck. (edit: lol, why so serious, this was meant to be humorous and not a complaint about Rust…)
Thanks to for the report and helping us to work with it, and to for the quick analysis and fix!

Discussion:
<ins> // run-pass fn main() {} #[derive(Clone)] pub struct Little; #[derive(Clone)] pub struct Big( Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, Little, ); </ins>

<ins> fn get_pair(_a: &mut u32, _b: &mut u32) {} macro_rules! x10 { ($($t:tt)*) => { $($t)* $($t)* $($t)* $($t)* $($t)* $($t)* $($t)* $($t)* $($t)* $($t)* } } #[allow(unused_assignments)] fn main() { let mut x = 1; get_pair(&mut x, &mut x); //~^ ERROR: cannot borrow `x` as mutable more than once at a time x10! { x10!{ x10!{ if x > 0 { x += 2 } else { x += 1 } } } } } </ins>

<ins> error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/issue-65131.rs:14:22 | LL |     get_pair(&mut x, &mut x); |     -------- ------  ^^^^^^ second mutable borrow occurs here |     |        | |     |        first mutable borrow occurs here |     first borrow later used by call error: aborting due to previous error For more information about this error, try `rustc --explain E0499`. </ins>