diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2024-08-01 13:12:00 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2024-08-05 09:17:46 -0400 |
| commit | c2186e14de00329fc563aed546b5fd10c11ea5db (patch) | |
| tree | a458d40a30440a4084828d37725feb5565a47606 | |
| parent | 2c34d58159b67a73db66af81bdbe32f1ce48dd5e (diff) | |
| download | rust-c2186e14de00329fc563aed546b5fd10c11ea5db.tar.gz rust-c2186e14de00329fc563aed546b5fd10c11ea5db.zip | |
Make `cargo dev deprecate` require a reason
| -rw-r--r-- | clippy_dev/src/main.rs | 4 | ||||
| -rw-r--r-- | clippy_dev/src/update_lints.rs | 8 | ||||
| -rw-r--r-- | clippy_lints/src/declared_lints.rs | 2 | ||||
| -rw-r--r-- | clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs | 46 |
4 files changed, 5 insertions, 55 deletions
diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index 366b52b25df..db7287aac21 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -74,7 +74,7 @@ fn main() { new_name, uplift, } => update_lints::rename(&old_name, new_name.as_ref().unwrap_or(&old_name), uplift), - DevCommand::Deprecate { name, reason } => update_lints::deprecate(&name, reason.as_deref()), + DevCommand::Deprecate { name, reason } => update_lints::deprecate(&name, &reason), } } @@ -223,7 +223,7 @@ enum DevCommand { name: String, #[arg(long, short)] /// The reason for deprecation - reason: Option<String>, + reason: String, }, } diff --git a/clippy_dev/src/update_lints.rs b/clippy_dev/src/update_lints.rs index ec0973a6213..880e4c3d7a0 100644 --- a/clippy_dev/src/update_lints.rs +++ b/clippy_dev/src/update_lints.rs @@ -303,7 +303,6 @@ pub fn rename(old_name: &str, new_name: &str, uplift: bool) { println!("note: `cargo uitest` still needs to be run to update the test results"); } -const DEFAULT_DEPRECATION_REASON: &str = "default deprecation note"; /// Runs the `deprecate` command /// /// This does the following: @@ -313,8 +312,7 @@ const DEFAULT_DEPRECATION_REASON: &str = "default deprecation note"; /// # Panics /// /// If a file path could not read from or written to -pub fn deprecate(name: &str, reason: Option<&str>) { - let reason = reason.unwrap_or(DEFAULT_DEPRECATION_REASON); +pub fn deprecate(name: &str, reason: &str) { let prefixed_name = if name.starts_with("clippy::") { name.to_owned() } else { @@ -357,10 +355,6 @@ pub fn deprecate(name: &str, reason: Option<&str>) { generate_lint_files(UpdateMode::Change, &lints, &deprecated_lints, &renamed_lints); println!("info: `{name}` has successfully been deprecated"); - - if reason == DEFAULT_DEPRECATION_REASON { - println!("note: the deprecation reason must be updated in `clippy_lints/src/deprecated_lints.rs`"); - } println!("note: you must run `cargo uitest` to update the test results"); } else { eprintln!("error: lint not found"); diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index 69f9eb6842b..69f7ca57554 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -14,8 +14,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ #[cfg(feature = "internal")] crate::utils::internal_lints::invalid_paths::INVALID_PATHS_INFO, #[cfg(feature = "internal")] - crate::utils::internal_lints::lint_without_lint_pass::DEFAULT_DEPRECATION_REASON_INFO, - #[cfg(feature = "internal")] crate::utils::internal_lints::lint_without_lint_pass::DEFAULT_LINT_INFO, #[cfg(feature = "internal")] crate::utils::internal_lints::lint_without_lint_pass::INVALID_CLIPPY_VERSION_ATTRIBUTE_INFO, diff --git a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs index 77e44cc0498..df342e48d63 100644 --- a/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs +++ b/clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs @@ -86,59 +86,17 @@ declare_clippy_lint! { "found clippy lint without `clippy::version` attribute" } -declare_clippy_lint! { - /// ### What it does - /// Checks for cases of an auto-generated deprecated lint without an updated reason, - /// i.e. `"default deprecation note"`. - /// - /// ### Why is this bad? - /// Indicates that the documentation is incomplete. - /// - /// ### Example - /// ```rust,ignore - /// declare_deprecated_lint! { - /// /// ### What it does - /// /// Nothing. This lint has been deprecated. - /// /// - /// /// ### Deprecation reason - /// /// TODO - /// #[clippy::version = "1.63.0"] - /// pub COOL_LINT, - /// "default deprecation note" - /// } - /// ``` - /// - /// Use instead: - /// ```rust,ignore - /// declare_deprecated_lint! { - /// /// ### What it does - /// /// Nothing. This lint has been deprecated. - /// /// - /// /// ### Deprecation reason - /// /// This lint has been replaced by `cooler_lint` - /// #[clippy::version = "1.63.0"] - /// pub COOL_LINT, - /// "this lint has been replaced by `cooler_lint`" - /// } - /// ``` - pub DEFAULT_DEPRECATION_REASON, - internal, - "found 'default deprecation note' in a deprecated lint declaration" -} - #[derive(Clone, Debug, Default)] pub struct LintWithoutLintPass { declared_lints: FxHashMap<Symbol, Span>, registered_lints: FxHashSet<Symbol>, } -impl_lint_pass!(LintWithoutLintPass => [DEFAULT_LINT, LINT_WITHOUT_LINT_PASS, INVALID_CLIPPY_VERSION_ATTRIBUTE, MISSING_CLIPPY_VERSION_ATTRIBUTE, DEFAULT_DEPRECATION_REASON]); +impl_lint_pass!(LintWithoutLintPass => [DEFAULT_LINT, LINT_WITHOUT_LINT_PASS, INVALID_CLIPPY_VERSION_ATTRIBUTE, MISSING_CLIPPY_VERSION_ATTRIBUTE]); impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) { - if is_lint_allowed(cx, DEFAULT_LINT, item.hir_id()) - || is_lint_allowed(cx, DEFAULT_DEPRECATION_REASON, item.hir_id()) - { + if is_lint_allowed(cx, DEFAULT_LINT, item.hir_id()) { return; } |
