When a string slice is used on a type containing the str the lint does not notice currently.
My use case is a Cow<&str> which isn't noticed by this lint.
Lint Name
string_slice
Reproducer
I tried this code:
#![warn(clippy::string_slice)]
use std::borrow::Cow;
fn main() {
let a = Cow::Borrowed("foo");
let b = "bar";
let x = &a[0..2];
let y = &b[0..2];
dbg!(&a, &b, x, y);
}
I expected to see this happen: x and y should create a warning.
Summary
When a string slice is used on a type containing the
str
the lint does not notice currently. My use case is aCow<&str>
which isn't noticed by this lint.Lint Name
string_slice
Reproducer
I tried this code:
I expected to see this happen: x and y should create a warning.
Instead, this happened: Only y creates a warning.
Version