Cargo build hung on compiling import (without reporting error once interrupted)

After adding rand = "0.8.5" to the Cargo.toml (following along with the rust book chapter 2) and doing cargo build the process got stuck at 'Compiling ppv-lite86 v0.2.21'. After a full five minutes with no CPU activity in task manager I used 'ctrl+Z' and the build completed with NO ERRORS! I went back and tried rerunning cargo build but as far as rust is concerned nothing needs to be done.

Running the guessing_game code with a call to rand::thread_rng().gen_range(1..100), appears to run fine but that says nothing about the reliability of the rest of the code imported with rand. Whether interrupting the hung compilation caused corruption or not is only part of my concern, the build would have happily sat there overnight waiting for Ctrl+Z completely hosing any automation chains!

Was this a random lightning event, newby error? have others experience or can explain this?

I’ve never heard of anyone experiencing a build getting stuck without CPU activity before now. (Did you happen to notice whether there was a rustc process running or only a cargo process?)

This should never happen and definitely isn’t the fault of rand, unless one of its dependencies has a build script that managed to hang somehow, but ppv-lite86 doesn't have any build script.

At a wild guess, perhaps you have antivirus software installed that interfered with normal execution. (Windows antivirus software is notorious for (1) disliking freshly generated executables such as the output of a compiler, and (2) sometimes changing the behavior of the operating system in non-conformant ways.) But that’s a guess. It could also be a CPU failure, memory bit flip, or other effectively random event.

All that said, rand 0.8.5 is four years old, and after you are done with your tutorial, you should consider upgrading to the latest version, 0.10.0 (you'll need to rename some things in your code). I just don’t think it's plausible that that has anything to do with the build failure.

This is on an old Windows 10 surface tablet (its just convenient for reading the book - will be doing real stuff on a decent machine), Task manager just lists everything under power shell which was sitting idle. The only CPU usage for the entire system worth mentioning was unrelated in the Firefox process. There have been no notifications by Windows Defender indicating it had tried to blunder in.
I noticed during the build that 0.10.0 was the new now, but since I'm working through the book figured I would leave it as recommended there until I get further than chapter 3.

Hopefully it's just beginners luck and as you suggested a random bit flip. A good reminder that s**t can happen even for bug free code.

Run cargo build -vvv and it will print exactly what it's running. At least you will see the specific command that is hanging.

cargo build -vvv -j1 will build one thing at a time, which will make the log easier to follow.

I've had the sporadic build issue not entirely unlike this. But running cargo clean and rebuilding solves that when it does happen.
Have you tried that yet?