Skip to content

Commit f87982c

Browse files
committed
Lint rename and utils/conf rename
1 parent 741a240 commit f87982c

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

clippy_lints/src/blacklisted_name.rs renamed to clippy_lints/src/disallowed_name.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ declare_clippy_lint! {
2323
}
2424

2525
#[derive(Clone, Debug)]
26-
pub struct DisAllowedName {
26+
pub struct DisallowedName {
2727
disallowlist: FxHashSet<String>,
2828
}
2929

30-
impl DisAllowedName {
30+
impl DisallowedName {
3131
pub fn new(disallowlist: FxHashSet<String>) -> Self {
3232
Self { disallowlist }
3333
}
3434
}
3535

36-
impl_lint_pass!(DisAllowedName => [DISALLOWED_NAME]);
36+
impl_lint_pass!(DisallowedName => [DISALLOWED_NAME]);
3737

38-
impl<'tcx> LateLintPass<'tcx> for DisAllowedName {
38+
impl<'tcx> LateLintPass<'tcx> for DisallowedName {
3939
fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) {
4040
if let PatKind::Binding(.., ident, _) = pat.kind {
4141
if self.disallowlist.contains(&ident.name.to_string()) {

clippy_lints/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
955955
store.register_late_pass(|| box overflow_check_conditional::OverflowCheckConditional);
956956
store.register_late_pass(|| box new_without_default::NewWithoutDefault::default());
957957
let disallowed_names = conf.disallowed_names.iter().cloned().collect::<FxHashSet<_>>();
958-
store.register_late_pass(move || box disallowed_name::DisAllowedName::new(disallowed_names.clone()));
958+
store.register_late_pass(move || box disallowed_name::DisallowedName::new(disallowed_names.clone()));
959959
let too_many_arguments_threshold1 = conf.too_many_arguments_threshold;
960960
let too_many_lines_threshold2 = conf.too_many_lines_threshold;
961961
store.register_late_pass(move || box functions::Functions::new(too_many_arguments_threshold1, too_many_lines_threshold2));
@@ -1859,6 +1859,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
18591859
ls.register_renamed("clippy::for_loop_over_option", "clippy::for_loops_over_fallibles");
18601860
ls.register_renamed("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles");
18611861
ls.register_renamed("clippy::identity_conversion", "clippy::useless_conversion");
1862+
ls.register_renamed("clippy::blacklisted_name", "clippy::disallowed_name");
18621863
}
18631864

18641865
// only exists to let the dogfood integration test works.

clippy_lints/src/utils/conf.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ macro_rules! define_Conf {
106106

107107
pub use self::helpers::Conf;
108108
define_Conf! {
109+
/// DEPRECATED LINT: BLACKLISTED_NAME. Use the Disallowed Names lint instead.
110+
(blacklisted_names, "blacklisted_names": Vec<String>, ["foo", "baz", "quux"].iter().map(ToString::to_string).collect()),
109111
/// Lint: DISALLOWED_NAME. The list of disallowed names to lint about. NB: `bar` is not here since it has legitimate uses
110112
(disallowed_names, "disallowed_names": Vec<String>, ["foo", "baz", "quux"].iter().map(ToString::to_string).collect()),
111113
/// Lint: COGNITIVE_COMPLEXITY. The maximum cognitive complexity a function can have
@@ -234,6 +236,12 @@ pub fn read(path: &Path) -> (Conf, Vec<Error>) {
234236
errors.push(Error::Toml(cyc_err));
235237
}
236238

239+
let block_ls_field = toml_ref.blacklisted_names;
240+
if !block_ls_field.is_empty() {
241+
let block_err = "found deprecated field `blacklisted-names`. Please use `disallowed-names` instead.".to_string();
242+
errors.push(Error::Toml(block_err));
243+
}
244+
237245
(toml, errors)
238246
},
239247
Err(e) => {

0 commit comments

Comments
 (0)