Skip to content

Commit ebb5ecf

Browse files
committed
Lint rename and utils/conf rename
1 parent 37254a3 commit ebb5ecf

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

+4-4
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
949949
store.register_late_pass(|| box overflow_check_conditional::OverflowCheckConditional);
950950
store.register_late_pass(|| box new_without_default::NewWithoutDefault::default());
951951
let disallowed_names = conf.disallowed_names.iter().cloned().collect::<FxHashSet<_>>();
952-
store.register_late_pass(move || box disallowed_name::DisAllowedName::new(disallowed_names.clone()));
952+
store.register_late_pass(move || box disallowed_name::DisallowedName::new(disallowed_names.clone()));
953953
let too_many_arguments_threshold1 = conf.too_many_arguments_threshold;
954954
let too_many_lines_threshold2 = conf.too_many_lines_threshold;
955955
store.register_late_pass(move || box functions::Functions::new(too_many_arguments_threshold1, too_many_lines_threshold2));
@@ -1843,6 +1843,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
18431843
ls.register_renamed("clippy::for_loop_over_option", "clippy::for_loops_over_fallibles");
18441844
ls.register_renamed("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles");
18451845
ls.register_renamed("clippy::identity_conversion", "clippy::useless_conversion");
1846+
ls.register_renamed("clippy::blacklisted_name", "clippy::disallowed_name");
18461847
}
18471848

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

clippy_lints/src/utils/conf.rs

+8
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)