rustdoc: Only inject extern crates if not present
auto merge of #12361 : sfackler/rust/rustdoc-test-extern, r=alexcrichton