Make cargo dev deprecate
require a reason
This commit is contained in:
parent
2c34d58159
commit
c2186e14de
@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -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 @@ pub fn rename(old_name: &str, new_name: &str, uplift: bool) {
|
||||
/// # 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");
|
||||
|
@ -14,8 +14,6 @@
|
||||
#[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,
|
||||
|
@ -86,59 +86,17 @@
|
||||
"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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user