Made fail_bounds_check more careful with strings.

Fixes GH #11976.
auto merge of #12357 : chromatic/rust/gh_11976_fail_bounds_check_str, r=alexcrichton

Fixes #11976.