Capture rustc output in rustdoc tests

This helps prevent the unfortunate interleavings found in #12623.