syntax: Refactor diagnostics to focus on Writers

This commit alters the diagnostic emission machinery to be focused around a
Writer for emitting errors. This allows it to not hard-code emission of errors
to stderr (useful for other applications).
rustdoc: Capture all output from rustc by default

This helps prevent interleaving of error messages when running rustdoc tests.
This has an interesting bit of shuffling with I/O handles, but other than that
this is just using the APIs laid out in the previous commit.

Closes #12623
auto merge of #12627 : alexcrichton/rust/issue-12623, r=brson

This helps prevent the unfortunate interleavings found in #12623.