rustc: support dumping the AST as JSON

This is mostly useful for working on rustc, when one is unfamiliar with the
AST a particular construct will produce. It's a -Z flag as it's very much for
debugging.

Closes #10485
auto merge of #12387 : cmr/rust/ast-json, r=alexcrichton

See the commits