]> git.lizzy.rs Git - rust.git/commit
Auto merge of #38066 - bluss:string-slice-error, r=sfackler
authorbors <bors@rust-lang.org>
Tue, 3 Jan 2017 23:51:42 +0000 (23:51 +0000)
committerbors <bors@rust-lang.org>
Tue, 3 Jan 2017 23:51:42 +0000 (23:51 +0000)
commit468227129d08b52c4cf90313b29fdad1b80e596b
tree395f940c4de2fd358f5777c4f28b867a4174e2b6
parent8f62c2920077eb5cb81323142fc5dbe6ae8813c0
parentd83fff3b3b9dd0fd6eef862e97f883d171367041
Auto merge of #38066 - bluss:string-slice-error, r=sfackler

Use more specific panic message for &str slicing errors

Separate out of bounds errors from character boundary errors, and print
more details for character boundary errors.

It reports the first error it finds in:

1. begin out of bounds
2. end out of bounds
3. begin <= end violated
3. begin not char boundary
5. end not char boundary.

Example:

    &"abcαβγ"[..4]

    thread 'str::test_slice_fail_boundary_1' panicked at 'byte index 4 is not
    a char boundary; it is inside 'α' (bytes 3..5) of `abcαβγ`'

Fixes #38052
src/libcollectionstest/str.rs
src/libcore/str/mod.rs