-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
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.
Instead, this happened: Only y creates a warning.
Version
rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: x86_64-unknown-linux-gnu
release: 1.77.2
LLVM version: 17.0.6
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't