Skip to content

[ER] Useless slicing warning #8089

Description

@leonardo-m

What it does

Inspired by this issue:
rust-lang/rust#91625

In code like this:

fn main() {
    let s = "abc".to_string();
    let t = s.strip_prefix(&['a', 'x'][..]);
    println!("{:?}", t);
}

Clippy could suggest to write instead:

s.strip_prefix(&['a', 'x'])

Or even:

s.strip_prefix(['a', 'x'])

Lint Name

No response

Category

No response

Advantage

No response

Drawbacks

No response

Example

<code>

Could be written as:

<code>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions