Skip to content

Commit

Permalink
Pluralize disallowed_type lint
Browse files Browse the repository at this point in the history
This was brought up in [Zulip] and is also mentioned in the lint naming
conventions. Since this is still a nursery lint, I think there shouldn't
be any problem in renaming it.

[Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/disallow_type.20vs.20disallowed-types
  • Loading branch information
phansch authored and flip1995 committed Nov 18, 2021
1 parent 8dd1bce commit b7f1891
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 49 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Expand Up @@ -174,7 +174,7 @@ Current stable, released 2021-10-21

* [`needless_continue`]: Now also lints in `loop { continue; }` case
[#7477](https://github.com/rust-lang/rust-clippy/pull/7477)
* [`disallowed_type`]: Now also primitive types can be disallowed
* [`disallowed_types`]: Now also primitive types can be disallowed
[#7488](https://github.com/rust-lang/rust-clippy/pull/7488)
* [`manual_swap`]: Now also lints on xor swaps
[#7506](https://github.com/rust-lang/rust-clippy/pull/7506)
Expand Down Expand Up @@ -248,7 +248,7 @@ Released 2021-09-09
[#7403](https://github.com/rust-lang/rust-clippy/pull/7403)
* [`disallowed_script_idents`]
[#7400](https://github.com/rust-lang/rust-clippy/pull/7400)
* [`disallowed_type`]
* [`disallowed_types`]
[#7315](https://github.com/rust-lang/rust-clippy/pull/7315)
* [`missing_enforced_import_renames`]
[#7300](https://github.com/rust-lang/rust-clippy/pull/7300)
Expand Down Expand Up @@ -294,7 +294,7 @@ Released 2021-09-09
[#7379](https://github.com/rust-lang/rust-clippy/pull/7379)
* [`redundant_closure`]: Suggests `&mut` for `FnMut`
[#7437](https://github.com/rust-lang/rust-clippy/pull/7437)
* [`disallowed_method`], [`disallowed_type`]: The configuration values `disallowed-method` and `disallowed-type`
* [`disallowed_method`], [`disallowed_types`]: The configuration values `disallowed-method` and `disallowed-type`
no longer require fully qualified paths
[#7345](https://github.com/rust-lang/rust-clippy/pull/7345)
* [`zst_offset`]: Fixed lint invocation after it was accidentally suppressed
Expand Down Expand Up @@ -2823,7 +2823,7 @@ Released 2018-09-13
[`derive_ord_xor_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#derive_ord_xor_partial_ord
[`disallowed_method`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_method
[`disallowed_script_idents`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents
[`disallowed_type`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_type
[`disallowed_types`]: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
[`diverging_sub_expression`]: https://rust-lang.github.io/rust-clippy/master/index.html#diverging_sub_expression
[`doc_markdown`]: https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
[`double_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#double_comparisons
Expand Down
14 changes: 7 additions & 7 deletions clippy_lints/src/disallowed_type.rs
Expand Up @@ -43,18 +43,18 @@ declare_clippy_lint! {
/// use std::collections::HashMap;
/// ```
#[clippy::version = "1.55.0"]
pub DISALLOWED_TYPE,
pub DISALLOWED_TYPES,
nursery,
"use of a disallowed type"
"use of disallowed types"
}
#[derive(Clone, Debug)]
pub struct DisallowedType {
pub struct DisallowedTypes {
conf_disallowed: Vec<conf::DisallowedType>,
def_ids: FxHashMap<DefId, Option<String>>,
prim_tys: FxHashMap<PrimTy, Option<String>>,
}

impl DisallowedType {
impl DisallowedTypes {
pub fn new(conf_disallowed: Vec<conf::DisallowedType>) -> Self {
Self {
conf_disallowed,
Expand All @@ -80,9 +80,9 @@ impl DisallowedType {
}
}

impl_lint_pass!(DisallowedType => [DISALLOWED_TYPE]);
impl_lint_pass!(DisallowedTypes => [DISALLOWED_TYPES]);

impl<'tcx> LateLintPass<'tcx> for DisallowedType {
impl<'tcx> LateLintPass<'tcx> for DisallowedTypes {
fn check_crate(&mut self, cx: &LateContext<'_>) {
for conf in &self.conf_disallowed {
let (path, reason) = match conf {
Expand Down Expand Up @@ -125,7 +125,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedType {
fn emit(cx: &LateContext<'_>, name: &str, span: Span, reason: Option<&str>) {
span_lint_and_then(
cx,
DISALLOWED_TYPE,
DISALLOWED_TYPES,
span,
&format!("`{}` is not allowed according to config", name),
|diag| {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.register_lints.rs
Expand Up @@ -99,7 +99,7 @@ store.register_lints(&[
derive::UNSAFE_DERIVE_DESERIALIZE,
disallowed_method::DISALLOWED_METHOD,
disallowed_script_idents::DISALLOWED_SCRIPT_IDENTS,
disallowed_type::DISALLOWED_TYPE,
disallowed_type::DISALLOWED_TYPES,
doc::DOC_MARKDOWN,
doc::MISSING_ERRORS_DOC,
doc::MISSING_PANICS_DOC,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lib.register_nursery.rs
Expand Up @@ -7,7 +7,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
LintId::of(cognitive_complexity::COGNITIVE_COMPLEXITY),
LintId::of(copies::BRANCHES_SHARING_CODE),
LintId::of(disallowed_method::DISALLOWED_METHOD),
LintId::of(disallowed_type::DISALLOWED_TYPE),
LintId::of(disallowed_type::DISALLOWED_TYPES),
LintId::of(equatable_if_let::EQUATABLE_IF_LET),
LintId::of(fallible_impl_from::FALLIBLE_IMPL_FROM),
LintId::of(floating_point_arithmetic::IMPRECISE_FLOPS),
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/lib.rs
Expand Up @@ -827,7 +827,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_early_pass(move || Box::new(module_style::ModStyle));
store.register_late_pass(|| Box::new(unused_async::UnusedAsync));
let disallowed_types = conf.disallowed_types.clone();
store.register_late_pass(move || Box::new(disallowed_type::DisallowedType::new(disallowed_types.clone())));
store.register_late_pass(move || Box::new(disallowed_type::DisallowedTypes::new(disallowed_types.clone())));
let import_renames = conf.enforced_import_renames.clone();
store.register_late_pass(move || {
Box::new(missing_enforced_import_rename::ImportRename::new(
Expand Down Expand Up @@ -924,6 +924,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
ls.register_renamed("clippy::zero_width_space", "clippy::invisible_characters");
ls.register_renamed("clippy::single_char_push_str", "clippy::single_char_add_str");
ls.register_renamed("clippy::if_let_some_result", "clippy::match_result_ok");
ls.register_renamed("clippy::disallowed_type", "clippy::disallowed_types");

// uplifted lints
ls.register_renamed("clippy::invalid_ref", "invalid_value");
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/conf.rs
Expand Up @@ -23,7 +23,7 @@ pub enum DisallowedMethod {
WithReason { path: String, reason: Option<String> },
}

/// A single disallowed type, used by the `DISALLOWED_TYPE` lint.
/// A single disallowed type, used by the `DISALLOWED_TYPES` lint.
#[derive(Clone, Debug, Deserialize)]
#[serde(untagged)]
pub enum DisallowedType {
Expand Down Expand Up @@ -260,7 +260,7 @@ define_Conf! {
///
/// The list of disallowed methods, written as fully qualified paths.
(disallowed_methods: Vec<crate::utils::conf::DisallowedMethod> = Vec::new()),
/// Lint: DISALLOWED_TYPE.
/// Lint: DISALLOWED_TYPES.
///
/// The list of disallowed types, written as fully qualified paths.
(disallowed_types: Vec<crate::utils::conf::DisallowedType> = Vec::new()),
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/toml_disallowed_type/conf_disallowed_type.rs
@@ -1,4 +1,4 @@
#![warn(clippy::disallowed_type)]
#![warn(clippy::disallowed_types)]

extern crate quote;
extern crate syn;
Expand Down
Expand Up @@ -4,7 +4,7 @@ error: `std::sync::atomic::AtomicU32` is not allowed according to config
LL | use std::sync::atomic::AtomicU32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::disallowed-type` implied by `-D warnings`
= note: `-D clippy::disallowed-types` implied by `-D warnings`

error: `std::time::Instant` is not allowed according to config
--> $DIR/conf_disallowed_type.rs:8:1
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/rename.fixed
Expand Up @@ -17,6 +17,7 @@
#![allow(clippy::invisible_characters)]
#![allow(clippy::single_char_add_str)]
#![allow(clippy::match_result_ok)]
#![allow(clippy::disallowed_types)]
// uplifted lints
#![allow(invalid_value)]
#![allow(array_into_iter)]
Expand Down Expand Up @@ -49,6 +50,7 @@
#![warn(clippy::invisible_characters)]
#![warn(clippy::single_char_add_str)]
#![warn(clippy::match_result_ok)]
#![warn(clippy::disallowed_types)]
// uplifted lints
#![warn(invalid_value)]
#![warn(array_into_iter)]
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/rename.rs
Expand Up @@ -17,6 +17,7 @@
#![allow(clippy::invisible_characters)]
#![allow(clippy::single_char_add_str)]
#![allow(clippy::match_result_ok)]
#![allow(clippy::disallowed_types)]
// uplifted lints
#![allow(invalid_value)]
#![allow(array_into_iter)]
Expand Down Expand Up @@ -49,6 +50,7 @@
#![warn(clippy::zero_width_space)]
#![warn(clippy::single_char_push_str)]
#![warn(clippy::if_let_some_result)]
#![warn(clippy::disallowed_type)]
// uplifted lints
#![warn(clippy::invalid_ref)]
#![warn(clippy::into_iter_on_array)]
Expand Down

0 comments on commit b7f1891

Please sign in to comment.