Skip to content

cmp_owned provides a confusing suggestion #8103

@Volker-Weissmann

Description

@Volker-Weissmann

Description

Example:

let my_string = String::from("hello"); let eq = my_string == "hello".to_owned(); 

Why does clippy suggest changing "hello".to_owned() into *"hello" instead of "hello"?

This created confusion for beginners because dereferencing a string literal isn't something you normally do.

Version

rustc 1.58.0-nightly (4961b107f 2021-11-04) binary: rustc commit-hash: 4961b107f204e15b26961eab0685df6be3ab03c6 commit-date: 2021-11-04 host: x86_64-unknown-linux-gnu release: 1.58.0-nightly LLVM version: 13.0.0 

Additional Labels

@rustbot label +C-enhancement

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