rustdoc: Check for href when prepending rootPath

Fixes #18354.
auto merge of #19453 : pshc/rust/rustdoc-check-a-href, r=alexcrichton

Fixes the JS error in #18354 at least. I don't know if there's a more underlying issue that needs addressing.