2024-08-24 12:43:34 -05:00
|
|
|
#![warn(clippy::string_slice)]
|
|
|
|
#![allow(clippy::no_effect)]
|
2024-08-18 07:50:29 -05:00
|
|
|
|
2024-08-24 12:43:34 -05:00
|
|
|
use std::borrow::Cow;
|
2021-10-25 02:46:47 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
&"Ölkanne"[1..];
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: indexing into a string may panic if the index is within a UTF-8 character
|
|
|
|
//~| NOTE: `-D clippy::string-slice` implied by `-D warnings`
|
2021-10-25 02:46:47 -05:00
|
|
|
let m = "Mötörhead";
|
|
|
|
&m[2..5];
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: indexing into a string may panic if the index is within a UTF-8 character
|
2021-10-25 02:46:47 -05:00
|
|
|
let s = String::from(m);
|
|
|
|
&s[0..2];
|
2023-07-28 14:35:48 -05:00
|
|
|
//~^ ERROR: indexing into a string may panic if the index is within a UTF-8 character
|
2024-08-18 07:50:29 -05:00
|
|
|
let a = Cow::Borrowed("foo");
|
|
|
|
&a[0..3];
|
|
|
|
//~^ ERROR: indexing into a string may panic if the index is within a UTF-8 character
|
2021-10-25 02:46:47 -05:00
|
|
|
}
|