diff options
Diffstat (limited to 'src/tools/clippy/src/docs/string_slice.txt')
-rw-r--r-- | src/tools/clippy/src/docs/string_slice.txt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/string_slice.txt b/src/tools/clippy/src/docs/string_slice.txt new file mode 100644 index 000000000..3d9e49dd3 --- /dev/null +++ b/src/tools/clippy/src/docs/string_slice.txt @@ -0,0 +1,17 @@ +### What it does +Checks for slice operations on strings + +### Why is this bad? +UTF-8 characters span multiple bytes, and it is easy to inadvertently confuse character +counts and string indices. This may lead to panics, and should warrant some test cases +containing wide UTF-8 characters. This lint is most useful in code that should avoid +panics at all costs. + +### Known problems +Probably lots of false positives. If an index comes from a known valid position (e.g. +obtained via `char_indices` over the same string), it is totally OK. + +# Example +``` +&"Ölkanne"[1..]; +```
\ No newline at end of file |