Handle negative numbers in `sqrt` properly.

Closes #9987.
auto merge of #18174 : huonw/rust/fix-sqrt, r=alexcrichton

Closes #9987.