Skip to content

Commit c2186e1

Browse files
committed
Make cargo dev deprecate require a reason
1 parent 2c34d58 commit c2186e1

File tree

4 files changed

+5
-55
lines changed

4 files changed

+5
-55
lines changed

clippy_dev/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn main() {
7474
new_name,
7575
uplift,
7676
} => update_lints::rename(&old_name, new_name.as_ref().unwrap_or(&old_name), uplift),
77-
DevCommand::Deprecate { name, reason } => update_lints::deprecate(&name, reason.as_deref()),
77+
DevCommand::Deprecate { name, reason } => update_lints::deprecate(&name, &reason),
7878
}
7979
}
8080

@@ -223,7 +223,7 @@ enum DevCommand {
223223
name: String,
224224
#[arg(long, short)]
225225
/// The reason for deprecation
226-
reason: Option<String>,
226+
reason: String,
227227
},
228228
}
229229

clippy_dev/src/update_lints.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ pub fn rename(old_name: &str, new_name: &str, uplift: bool) {
303303
println!("note: `cargo uitest` still needs to be run to update the test results");
304304
}
305305

306-
const DEFAULT_DEPRECATION_REASON: &str = "default deprecation note";
307306
/// Runs the `deprecate` command
308307
///
309308
/// This does the following:
@@ -313,8 +312,7 @@ const DEFAULT_DEPRECATION_REASON: &str = "default deprecation note";
313312
/// # Panics
314313
///
315314
/// If a file path could not read from or written to
316-
pub fn deprecate(name: &str, reason: Option<&str>) {
317-
let reason = reason.unwrap_or(DEFAULT_DEPRECATION_REASON);
315+
pub fn deprecate(name: &str, reason: &str) {
318316
let prefixed_name = if name.starts_with("clippy::") {
319317
name.to_owned()
320318
} else {
@@ -357,10 +355,6 @@ pub fn deprecate(name: &str, reason: Option<&str>) {
357355

358356
generate_lint_files(UpdateMode::Change, &lints, &deprecated_lints, &renamed_lints);
359357
println!("info: `{name}` has successfully been deprecated");
360-
361-
if reason == DEFAULT_DEPRECATION_REASON {
362-
println!("note: the deprecation reason must be updated in `clippy_lints/src/deprecated_lints.rs`");
363-
}
364358
println!("note: you must run `cargo uitest` to update the test results");
365359
} else {
366360
eprintln!("error: lint not found");

clippy_lints/src/declared_lints.rs

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
1414
#[cfg(feature = "internal")]
1515
crate::utils::internal_lints::invalid_paths::INVALID_PATHS_INFO,
1616
#[cfg(feature = "internal")]
17-
crate::utils::internal_lints::lint_without_lint_pass::DEFAULT_DEPRECATION_REASON_INFO,
18-
#[cfg(feature = "internal")]
1917
crate::utils::internal_lints::lint_without_lint_pass::DEFAULT_LINT_INFO,
2018
#[cfg(feature = "internal")]
2119
crate::utils::internal_lints::lint_without_lint_pass::INVALID_CLIPPY_VERSION_ATTRIBUTE_INFO,

clippy_lints/src/utils/internal_lints/lint_without_lint_pass.rs

+2-44
Original file line numberDiff line numberDiff line change
@@ -86,59 +86,17 @@ declare_clippy_lint! {
8686
"found clippy lint without `clippy::version` attribute"
8787
}
8888

89-
declare_clippy_lint! {
90-
/// ### What it does
91-
/// Checks for cases of an auto-generated deprecated lint without an updated reason,
92-
/// i.e. `"default deprecation note"`.
93-
///
94-
/// ### Why is this bad?
95-
/// Indicates that the documentation is incomplete.
96-
///
97-
/// ### Example
98-
/// ```rust,ignore
99-
/// declare_deprecated_lint! {
100-
/// /// ### What it does
101-
/// /// Nothing. This lint has been deprecated.
102-
/// ///
103-
/// /// ### Deprecation reason
104-
/// /// TODO
105-
/// #[clippy::version = "1.63.0"]
106-
/// pub COOL_LINT,
107-
/// "default deprecation note"
108-
/// }
109-
/// ```
110-
///
111-
/// Use instead:
112-
/// ```rust,ignore
113-
/// declare_deprecated_lint! {
114-
/// /// ### What it does
115-
/// /// Nothing. This lint has been deprecated.
116-
/// ///
117-
/// /// ### Deprecation reason
118-
/// /// This lint has been replaced by `cooler_lint`
119-
/// #[clippy::version = "1.63.0"]
120-
/// pub COOL_LINT,
121-
/// "this lint has been replaced by `cooler_lint`"
122-
/// }
123-
/// ```
124-
pub DEFAULT_DEPRECATION_REASON,
125-
internal,
126-
"found 'default deprecation note' in a deprecated lint declaration"
127-
}
128-
12989
#[derive(Clone, Debug, Default)]
13090
pub struct LintWithoutLintPass {
13191
declared_lints: FxHashMap<Symbol, Span>,
13292
registered_lints: FxHashSet<Symbol>,
13393
}
13494

135-
impl_lint_pass!(LintWithoutLintPass => [DEFAULT_LINT, LINT_WITHOUT_LINT_PASS, INVALID_CLIPPY_VERSION_ATTRIBUTE, MISSING_CLIPPY_VERSION_ATTRIBUTE, DEFAULT_DEPRECATION_REASON]);
95+
impl_lint_pass!(LintWithoutLintPass => [DEFAULT_LINT, LINT_WITHOUT_LINT_PASS, INVALID_CLIPPY_VERSION_ATTRIBUTE, MISSING_CLIPPY_VERSION_ATTRIBUTE]);
13696

13797
impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
13898
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
139-
if is_lint_allowed(cx, DEFAULT_LINT, item.hir_id())
140-
|| is_lint_allowed(cx, DEFAULT_DEPRECATION_REASON, item.hir_id())
141-
{
99+
if is_lint_allowed(cx, DEFAULT_LINT, item.hir_id()) {
142100
return;
143101
}
144102

0 commit comments

Comments
 (0)