update error message, refactor disallowed_method
This commit is contained in:
parent
3886edb05a
commit
f9da2946d8
@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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>();
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user