Skip to content

Commit f773479

Browse files
committed
Reverting deprecated lint collection from deprecated_lints.rs
1 parent 4a1da74 commit f773479

File tree

3 files changed

+21
-62
lines changed

3 files changed

+21
-62
lines changed

clippy_lints/src/deprecated_lints.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
/// This struct fakes the `Lint` declaration that is usually created by `declare_lint!`. This
2-
/// enables the simple extraction of the metadata without changing the current deprecation
3-
/// declaration.
4-
pub struct ClippyDeprecatedLint;
5-
61
macro_rules! declare_deprecated_lint {
7-
{ $(#[$attr:meta])* pub $name: ident, $_reason: expr} => {
8-
$(#[$attr])*
9-
#[allow(dead_code)]
10-
pub static $name: ClippyDeprecatedLint = ClippyDeprecatedLint {};
2+
(pub $name: ident, $_reason: expr) => {
3+
declare_lint!(pub $name, Allow, "deprecated lint")
114
}
125
}
136

clippy_lints/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ macro_rules! extract_msrv_attr {
162162
mod consts;
163163
#[macro_use]
164164
mod utils;
165-
#[cfg(feature = "metadata-collector-lint")]
166-
mod deprecated_lints;
167165

168166
// begin lints modules, do not remove this comment, it’s used in `update_lints`
169167
mod absurd_extreme_comparisons;

clippy_lints/src/utils/internal_lints/metadata_collector.rs

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::path::Path;
2828

2929
use crate::utils::internal_lints::is_lint_ref_type;
3030
use clippy_utils::{
31-
diagnostics::span_lint, last_path_segment, match_def_path, match_function_call, match_path, paths, ty::match_type,
31+
diagnostics::span_lint, last_path_segment, match_function_call, match_path, paths, ty::match_type,
3232
ty::walk_ptrs_ty_depth,
3333
};
3434

@@ -41,8 +41,6 @@ const BLACK_LISTED_LINTS: [&str; 3] = ["lint_author", "deep_code_inspection", "i
4141
const IGNORED_LINT_GROUPS: [&str; 1] = ["clippy::all"];
4242
/// Lints within this group will be excluded from the collection
4343
const EXCLUDED_LINT_GROUPS: [&str; 1] = ["clippy::internal"];
44-
/// Collected deprecated lint will be assigned to this group in the JSON output
45-
const DEPRECATED_LINT_GROUP_STR: &str = "DEPRECATED";
4644

4745
const LINT_EMISSION_FUNCTIONS: [&[&str]; 7] = [
4846
&["clippy_utils", "diagnostics", "span_lint"],
@@ -68,7 +66,6 @@ const SUGGESTION_FUNCTIONS: [&[&str]; 2] = [
6866
&["clippy_utils", "diagnostics", "multispan_sugg"],
6967
&["clippy_utils", "diagnostics", "multispan_sugg_with_applicability"],
7068
];
71-
const DEPRECATED_LINT_TYPE: [&str; 3] = ["clippy_lints", "deprecated_lints", "ClippyDeprecatedLint"];
7269

7370
/// The index of the applicability name of `paths::APPLICABILITY_VALUES`
7471
const APPLICABILITY_NAME_INDEX: usize = 2;
@@ -228,42 +225,23 @@ impl<'hir> LateLintPass<'hir> for MetadataCollector {
228225
/// }
229226
/// ```
230227
fn check_item(&mut self, cx: &LateContext<'hir>, item: &'hir Item<'_>) {
231-
if let ItemKind::Static(ref ty, Mutability::Not, _) = item.kind {
232-
// Normal lint
233-
if_chain! {
234-
// item validation
235-
if is_lint_ref_type(cx, ty);
236-
// blacklist check
237-
let lint_name = sym_to_string(item.ident.name).to_ascii_lowercase();
238-
if !BLACK_LISTED_LINTS.contains(&lint_name.as_str());
239-
// metadata extraction
240-
if let Some(group) = get_lint_group_or_lint(cx, &lint_name, item);
241-
if let Some(docs) = extract_attr_docs_or_lint(cx, item);
242-
then {
243-
self.lints.push(LintMetadata::new(
244-
lint_name,
245-
SerializableSpan::from_item(cx, item),
246-
group,
247-
docs,
248-
));
249-
}
250-
}
251-
252-
if_chain! {
253-
if is_deprecated_lint(cx, ty);
254-
// blacklist check
255-
let lint_name = sym_to_string(item.ident.name).to_ascii_lowercase();
256-
if !BLACK_LISTED_LINTS.contains(&lint_name.as_str());
257-
// Metadata the little we can get from a deprecated lint
258-
if let Some(docs) = extract_attr_docs_or_lint(cx, item);
259-
then {
260-
self.lints.push(LintMetadata::new(
261-
lint_name,
262-
SerializableSpan::from_item(cx, item),
263-
DEPRECATED_LINT_GROUP_STR.to_string(),
264-
docs,
265-
));
266-
}
228+
if_chain! {
229+
// item validation
230+
if let ItemKind::Static(ref ty, Mutability::Not, _) = item.kind;
231+
if is_lint_ref_type(cx, ty);
232+
// blacklist check
233+
let lint_name = sym_to_string(item.ident.name).to_ascii_lowercase();
234+
if !BLACK_LISTED_LINTS.contains(&lint_name.as_str());
235+
// metadata extraction
236+
if let Some(group) = get_lint_group_or_lint(cx, &lint_name, item);
237+
if let Some(docs) = extract_attr_docs_or_lint(cx, item);
238+
then {
239+
self.lints.push(LintMetadata::new(
240+
lint_name,
241+
SerializableSpan::from_item(cx, item),
242+
group,
243+
docs,
244+
));
267245
}
268246
}
269247
}
@@ -290,7 +268,7 @@ impl<'hir> LateLintPass<'hir> for MetadataCollector {
290268
// - src/misc.rs:734:9
291269
// - src/methods/mod.rs:3545:13
292270
// - src/methods/mod.rs:3496:13
293-
// We are basically unable to resolve the lint name itself.
271+
// We are basically unable to resolve the lint name it self.
294272
return;
295273
}
296274

@@ -369,16 +347,6 @@ fn get_lint_group(cx: &LateContext<'_>, lint_id: LintId) -> Option<String> {
369347
None
370348
}
371349

372-
fn is_deprecated_lint(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
373-
if let hir::TyKind::Path(ref path) = ty.kind {
374-
if let hir::def::Res::Def(DefKind::Struct, def_id) = cx.qpath_res(path, ty.hir_id) {
375-
return match_def_path(cx, def_id, &DEPRECATED_LINT_TYPE);
376-
}
377-
}
378-
379-
false
380-
}
381-
382350
// ==================================================================
383351
// Lint emission
384352
// ==================================================================

0 commit comments

Comments
 (0)