]> git.lizzy.rs Git - rust.git/commitdiff
don't create owned values for comparison (clippy::cmp_owned)
authorMatthias Krüger <matthias.krueger@famsik.de>
Sat, 5 Dec 2020 12:32:08 +0000 (13:32 +0100)
committerMatthias Krüger <matthias.krueger@famsik.de>
Tue, 8 Dec 2020 19:27:48 +0000 (20:27 +0100)
compiler/rustc_lint/src/nonstandard_style.rs

index 2720c376774e8ff285dd6f8903797ff34903fc42..6d61b86f32ef90155f131c86331cb7c0f1af1a70 100644 (file)
@@ -131,7 +131,7 @@ fn check_case(&self, cx: &EarlyContext<'_>, sort: &str, ident: &Ident) {
                 let cc = to_camel_case(name);
                 // We cannot provide meaningful suggestions
                 // if the characters are in the category of "Lowercase Letter".
-                if name.to_string() != cc {
+                if *name != cc {
                     err.span_suggestion(
                         ident.span,
                         "convert the identifier to upper camel case",
@@ -271,7 +271,7 @@ fn is_snake_case(ident: &str) -> bool {
                 let mut err = lint.build(&msg);
                 // We cannot provide meaningful suggestions
                 // if the characters are in the category of "Uppercase Letter".
-                if name.to_string() != sc {
+                if *name != sc {
                     // We have a valid span in almost all cases, but we don't have one when linting a crate
                     // name provided via the command line.
                     if !ident.span.is_dummy() {
@@ -455,7 +455,7 @@ fn check_upper_case(cx: &LateContext<'_>, sort: &str, ident: &Ident) {
                     lint.build(&format!("{} `{}` should have an upper case name", sort, name));
                 // We cannot provide meaningful suggestions
                 // if the characters are in the category of "Lowercase Letter".
-                if name.to_string() != uc {
+                if *name != uc {
                     err.span_suggestion(
                         ident.span,
                         "convert the identifier to upper case",