about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrank <lifrank@grinnell.edu>2020-09-25 09:38:19 -0500
committerFrank <lifrank@grinnell.edu>2020-09-25 11:09:04 -0500
commitf9da2946d81a973b3c25aa5f4739ac7e05c27278 (patch)
tree55f58fe327e6a47476b83d7cab94fe325b846cf7
parent3886edb05a2b570664f7249620766582e55a74aa (diff)
downloadrust-f9da2946d81a973b3c25aa5f4739ac7e05c27278.tar.gz
rust-f9da2946d81a973b3c25aa5f4739ac7e05c27278.zip
update error message, refactor disallowed_method
-rw-r--r--clippy_lints/src/disallowed_method.rs17
-rw-r--r--tests/ui-toml/toml_disallowed_method/conf_disallowed_method.stderr4
-rw-r--r--tests/ui/disallowed_method.stderr6
3 files changed, 13 insertions, 14 deletions
diff --git a/clippy_lints/src/disallowed_method.rs b/clippy_lints/src/disallowed_method.rs
index eea369924a6..603f776e688 100644
--- a/clippy_lints/src/disallowed_method.rs
+++ b/clippy_lints/src/disallowed_method.rs
@@ -27,7 +27,7 @@ declare_clippy_lint! {
     /// ```
     pub DISALLOWED_METHOD,
     nursery,
-    "used disallowed method call"
+    "use of a disallowed method call"
 }
 
 #[derive(Clone, Debug)]
@@ -55,18 +55,17 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedMethod {
 
             let method_call = cx.get_def_path(def_id);
             if self.disallowed.contains(&method_call) {
+                let method = method_call
+                    .iter()
+                    .map(|s| s.to_ident_string())
+                    .collect::<Vec<_>>()
+                    .join("::");
+
                 span_lint(
                     cx,
                     DISALLOWED_METHOD,
                     expr.span,
-                    &format!(
-                        "Use of a disallowed method `{}`",
-                        method_call
-                            .iter()
-                            .map(|s| s.to_ident_string())
-                            .collect::<Vec<_>>()
-                            .join("::"),
-                    ),
+                    &format!("use of a disallowed method `{}`", method),
                 );
             }
         }
diff --git a/tests/ui-toml/toml_disallowed_method/conf_disallowed_method.stderr b/tests/ui-toml/toml_disallowed_method/conf_disallowed_method.stderr
index 5da551cb430..ed91b5a6796 100644
--- a/tests/ui-toml/toml_disallowed_method/conf_disallowed_method.stderr
+++ b/tests/ui-toml/toml_disallowed_method/conf_disallowed_method.stderr
@@ -1,4 +1,4 @@
-error: Use of a disallowed method `regex::re_unicode::Regex::is_match`
+error: use of a disallowed method `regex::re_unicode::Regex::is_match`
   --> $DIR/conf_disallowed_method.rs:10:5
    |
 LL |     re.is_match("abc");
@@ -6,7 +6,7 @@ LL |     re.is_match("abc");
    |
    = note: `-D clippy::disallowed-method` implied by `-D warnings`
 
-error: Use of a disallowed method `core::iter::traits::iterator::Iterator::sum`
+error: use of a disallowed method `core::iter::traits::iterator::Iterator::sum`
   --> $DIR/conf_disallowed_method.rs:12:5
    |
 LL |     a.iter().sum::<i32>();
diff --git a/tests/ui/disallowed_method.stderr b/tests/ui/disallowed_method.stderr
index 93dabf38cfc..40db1b946d8 100644
--- a/tests/ui/disallowed_method.stderr
+++ b/tests/ui/disallowed_method.stderr
@@ -1,4 +1,4 @@
-error: Use of a disallowed method `disallowed_method::Baz::bad_method`
+error: use of a disallowed method `disallowed_method::Baz::bad_method`
   --> $DIR/disallowed_method.rs:48:5
    |
 LL |     b.bad_method();
@@ -6,13 +6,13 @@ LL |     b.bad_method();
    |
    = note: `-D clippy::disallowed-method` implied by `-D warnings`
 
-error: Use of a disallowed method `disallowed_method::Baz::bad_method`
+error: use of a disallowed method `disallowed_method::Baz::bad_method`
   --> $DIR/disallowed_method.rs:49:5
    |
 LL |     c.bad_method();
    |     ^^^^^^^^^^^^^^
 
-error: Use of a disallowed method `disallowed_method::Foo::bad_method`
+error: use of a disallowed method `disallowed_method::Foo::bad_method`
   --> $DIR/disallowed_method.rs:50:5
    |
 LL |     f.bad_method();