Skip to content

Commit 9b38fb7

Browse files
committed
Also pluralize disallowed_method(s) lint
To stay consistent with the sister lint disallowed_type, also rename the disallowed_method lint to disallowed_methods.
1 parent a0d81d1 commit 9b38fb7

12 files changed

+67
-54
lines changed

CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Current beta, release 2021-12-02
7070
[#7560](https://github.com/rust-lang/rust-clippy/pull/7560)
7171
* [`unnecessary_unwrap`]: Now also checks for `expect`s
7272
[#7584](https://github.com/rust-lang/rust-clippy/pull/7584)
73-
* [`disallowed_method`]: Allow adding a reason that will be displayed with the
73+
* [`disallowed_methods`]: Allow adding a reason that will be displayed with the
7474
lint message
7575
[#7621](https://github.com/rust-lang/rust-clippy/pull/7621)
7676
* [`approx_constant`]: Now checks the MSRV for `LOG10_2` and `LOG2_10`
@@ -294,7 +294,7 @@ Released 2021-09-09
294294
[#7379](https://github.com/rust-lang/rust-clippy/pull/7379)
295295
* [`redundant_closure`]: Suggests `&mut` for `FnMut`
296296
[#7437](https://github.com/rust-lang/rust-clippy/pull/7437)
297-
* [`disallowed_method`], [`disallowed_types`]: The configuration values `disallowed-method` and `disallowed-type`
297+
* [`disallowed_methods`], [`disallowed_types`]: The configuration values `disallowed-method` and `disallowed-type`
298298
no longer require fully qualified paths
299299
[#7345](https://github.com/rust-lang/rust-clippy/pull/7345)
300300
* [`zst_offset`]: Fixed lint invocation after it was accidentally suppressed
@@ -703,7 +703,7 @@ Released 2021-05-06
703703

704704
### Enhancements
705705

706-
* [`disallowed_method`]: Now supports functions in addition to methods
706+
* [`disallowed_methods`]: Now supports functions in addition to methods
707707
[#6674](https://github.com/rust-lang/rust-clippy/pull/6674)
708708
* [`upper_case_acronyms`]: Added a new configuration `upper-case-acronyms-aggressive` to
709709
trigger the lint if there is more than one uppercase character next to each other
@@ -1044,7 +1044,7 @@ Released 2020-12-31
10441044

10451045
* [`field_reassign_with_default`] [#5911](https://github.com/rust-lang/rust-clippy/pull/5911)
10461046
* [`await_holding_refcell_ref`] [#6029](https://github.com/rust-lang/rust-clippy/pull/6029)
1047-
* [`disallowed_method`] [#6081](https://github.com/rust-lang/rust-clippy/pull/6081)
1047+
* [`disallowed_methods`] [#6081](https://github.com/rust-lang/rust-clippy/pull/6081)
10481048
* [`inline_asm_x86_att_syntax`] [#6092](https://github.com/rust-lang/rust-clippy/pull/6092)
10491049
* [`inline_asm_x86_intel_syntax`] [#6092](https://github.com/rust-lang/rust-clippy/pull/6092)
10501050
* [`from_iter_instead_of_collect`] [#6101](https://github.com/rust-lang/rust-clippy/pull/6101)
@@ -2821,7 +2821,7 @@ Released 2018-09-13
28212821
[`derivable_impls`]: https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls
28222822
[`derive_hash_xor_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_hash_xor_eq
28232823
[`derive_ord_xor_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_ord_xor_partial_ord
2824-
[`disallowed_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_method
2824+
[`disallowed_methods`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
28252825
[`disallowed_script_idents`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents
28262826
[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
28272827
[`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression

clippy_lints/src/disallowed_method.rs renamed to clippy_lints/src/disallowed_methods.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ declare_clippy_lint! {
4848
/// xs.push(123); // Vec::push is _not_ disallowed in the config.
4949
/// ```
5050
#[clippy::version = "1.49.0"]
51-
pub DISALLOWED_METHOD,
51+
pub DISALLOWED_METHODS,
5252
nursery,
5353
"use of a disallowed method call"
5454
}
5555

5656
#[derive(Clone, Debug)]
57-
pub struct DisallowedMethod {
57+
pub struct DisallowedMethods {
5858
conf_disallowed: Vec<conf::DisallowedMethod>,
5959
disallowed: DefIdMap<Option<String>>,
6060
}
6161

62-
impl DisallowedMethod {
62+
impl DisallowedMethods {
6363
pub fn new(conf_disallowed: Vec<conf::DisallowedMethod>) -> Self {
6464
Self {
6565
conf_disallowed,
@@ -68,9 +68,9 @@ impl DisallowedMethod {
6868
}
6969
}
7070

71-
impl_lint_pass!(DisallowedMethod => [DISALLOWED_METHOD]);
71+
impl_lint_pass!(DisallowedMethods => [DISALLOWED_METHODS]);
7272

73-
impl<'tcx> LateLintPass<'tcx> for DisallowedMethod {
73+
impl<'tcx> LateLintPass<'tcx> for DisallowedMethods {
7474
fn check_crate(&mut self, cx: &LateContext<'_>) {
7575
for conf in &self.conf_disallowed {
7676
let (path, reason) = match conf {
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedMethod {
9898
};
9999
let func_path = cx.tcx.def_path_str(def_id);
100100
let msg = format!("use of a disallowed method `{}`", func_path);
101-
span_lint_and_then(cx, DISALLOWED_METHOD, expr.span, &msg, |diag| {
101+
span_lint_and_then(cx, DISALLOWED_METHODS, expr.span, &msg, |diag| {
102102
if let Some(reason) = reason {
103103
diag.note(reason);
104104
}

clippy_lints/src/lib.register_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ store.register_lints(&[
9797
derive::DERIVE_ORD_XOR_PARTIAL_ORD,
9898
derive::EXPL_IMPL_CLONE_ON_COPY,
9999
derive::UNSAFE_DERIVE_DESERIALIZE,
100-
disallowed_method::DISALLOWED_METHOD,
100+
disallowed_methods::DISALLOWED_METHODS,
101101
disallowed_script_idents::DISALLOWED_SCRIPT_IDENTS,
102102
disallowed_types::DISALLOWED_TYPES,
103103
doc::DOC_MARKDOWN,

clippy_lints/src/lib.register_nursery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
66
LintId::of(attrs::EMPTY_LINE_AFTER_OUTER_ATTR),
77
LintId::of(cognitive_complexity::COGNITIVE_COMPLEXITY),
88
LintId::of(copies::BRANCHES_SHARING_CODE),
9-
LintId::of(disallowed_method::DISALLOWED_METHOD),
9+
LintId::of(disallowed_methods::DISALLOWED_METHODS),
1010
LintId::of(disallowed_types::DISALLOWED_TYPES),
1111
LintId::of(equatable_if_let::EQUATABLE_IF_LET),
1212
LintId::of(fallible_impl_from::FALLIBLE_IMPL_FROM),

clippy_lints/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ mod default_numeric_fallback;
194194
mod dereference;
195195
mod derivable_impls;
196196
mod derive;
197-
mod disallowed_method;
197+
mod disallowed_methods;
198198
mod disallowed_script_idents;
199199
mod disallowed_types;
200200
mod doc;
@@ -808,7 +808,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
808808
store.register_late_pass(|| Box::new(semicolon_if_nothing_returned::SemicolonIfNothingReturned));
809809
store.register_late_pass(|| Box::new(async_yields_async::AsyncYieldsAsync));
810810
let disallowed_methods = conf.disallowed_methods.clone();
811-
store.register_late_pass(move || Box::new(disallowed_method::DisallowedMethod::new(disallowed_methods.clone())));
811+
store.register_late_pass(move || Box::new(disallowed_methods::DisallowedMethods::new(disallowed_methods.clone())));
812812
store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86AttSyntax));
813813
store.register_early_pass(|| Box::new(asm_syntax::InlineAsmX86IntelSyntax));
814814
store.register_late_pass(|| Box::new(undropped_manually_drops::UndroppedManuallyDrops));
@@ -925,6 +925,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
925925
ls.register_renamed("clippy::single_char_push_str", "clippy::single_char_add_str");
926926
ls.register_renamed("clippy::if_let_some_result", "clippy::match_result_ok");
927927
ls.register_renamed("clippy::disallowed_type", "clippy::disallowed_types");
928+
ls.register_renamed("clippy::disallowed_method", "clippy::disallowed_methods");
928929

929930
// uplifted lints
930931
ls.register_renamed("clippy::invalid_ref", "invalid_value");

clippy_lints/src/utils/conf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct Rename {
1515
pub rename: String,
1616
}
1717

18-
/// A single disallowed method, used by the `DISALLOWED_METHOD` lint.
18+
/// A single disallowed method, used by the `DISALLOWED_METHODS` lint.
1919
#[derive(Clone, Debug, Deserialize)]
2020
#[serde(untagged)]
2121
pub enum DisallowedMethod {
@@ -256,7 +256,7 @@ define_Conf! {
256256
///
257257
/// Whether to allow certain wildcard imports (prelude, super in tests).
258258
(warn_on_all_wildcard_imports: bool = false),
259-
/// Lint: DISALLOWED_METHOD.
259+
/// Lint: DISALLOWED_METHODS.
260260
///
261261
/// The list of disallowed methods, written as fully qualified paths.
262262
(disallowed_methods: Vec<crate::utils::conf::DisallowedMethod> = Vec::new()),

tests/ui-toml/toml_disallowed_method/conf_disallowed_method.rs renamed to tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::disallowed_method)]
1+
#![warn(clippy::disallowed_methods)]
22

33
extern crate regex;
44
use regex::Regex;

tests/ui-toml/toml_disallowed_method/conf_disallowed_method.stderr renamed to tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
error: use of a disallowed method `regex::Regex::new`
2-
--> $DIR/conf_disallowed_method.rs:7:14
2+
--> $DIR/conf_disallowed_methods.rs:7:14
33
|
44
LL | let re = Regex::new(r"ab.*c").unwrap();
55
| ^^^^^^^^^^^^^^^^^^^^
66
|
7-
= note: `-D clippy::disallowed-method` implied by `-D warnings`
7+
= note: `-D clippy::disallowed-methods` implied by `-D warnings`
88

99
error: use of a disallowed method `regex::Regex::is_match`
10-
--> $DIR/conf_disallowed_method.rs:8:5
10+
--> $DIR/conf_disallowed_methods.rs:8:5
1111
|
1212
LL | re.is_match("abc");
1313
| ^^^^^^^^^^^^^^^^^^
1414
|
1515
= note: no matching allowed (from clippy.toml)
1616

1717
error: use of a disallowed method `std::iter::Iterator::sum`
18-
--> $DIR/conf_disallowed_method.rs:11:5
18+
--> $DIR/conf_disallowed_methods.rs:11:5
1919
|
2020
LL | a.iter().sum::<i32>();
2121
| ^^^^^^^^^^^^^^^^^^^^^

tests/ui/rename.fixed

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![allow(clippy::module_name_repetitions)]
77
#![allow(clippy::new_without_default)]
88
#![allow(clippy::redundant_static_lifetimes)]
9+
#![allow(clippy::cognitive_complexity)]
910
#![allow(clippy::bind_instead_of_map)]
1011
#![allow(clippy::box_collection)]
1112
#![allow(clippy::blocks_in_if_conditions)]
@@ -18,6 +19,7 @@
1819
#![allow(clippy::single_char_add_str)]
1920
#![allow(clippy::match_result_ok)]
2021
#![allow(clippy::disallowed_types)]
22+
#![allow(clippy::disallowed_methods)]
2123
// uplifted lints
2224
#![allow(invalid_value)]
2325
#![allow(array_into_iter)]
@@ -51,6 +53,7 @@
5153
#![warn(clippy::single_char_add_str)]
5254
#![warn(clippy::match_result_ok)]
5355
#![warn(clippy::disallowed_types)]
56+
#![warn(clippy::disallowed_methods)]
5457
// uplifted lints
5558
#![warn(invalid_value)]
5659
#![warn(array_into_iter)]

tests/ui/rename.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![allow(clippy::module_name_repetitions)]
77
#![allow(clippy::new_without_default)]
88
#![allow(clippy::redundant_static_lifetimes)]
9+
#![allow(clippy::cognitive_complexity)]
910
#![allow(clippy::bind_instead_of_map)]
1011
#![allow(clippy::box_collection)]
1112
#![allow(clippy::blocks_in_if_conditions)]
@@ -18,6 +19,7 @@
1819
#![allow(clippy::single_char_add_str)]
1920
#![allow(clippy::match_result_ok)]
2021
#![allow(clippy::disallowed_types)]
22+
#![allow(clippy::disallowed_methods)]
2123
// uplifted lints
2224
#![allow(invalid_value)]
2325
#![allow(array_into_iter)]
@@ -51,6 +53,7 @@
5153
#![warn(clippy::single_char_push_str)]
5254
#![warn(clippy::if_let_some_result)]
5355
#![warn(clippy::disallowed_type)]
56+
#![warn(clippy::disallowed_method)]
5457
// uplifted lints
5558
#![warn(clippy::invalid_ref)]
5659
#![warn(clippy::into_iter_on_array)]

0 commit comments

Comments
 (0)