RST writer: Fixes bug with links with duplicate text.

We now (a) use anonymous links for links with inline URLs, and
(b) use an inline link instead of a reference link if the
reference link would require a label that has already been
used for a different link.

Closes #511.