Skip to content

Commit 392b255

Browse files
committed
Auto merge of #11712 - Alexendoo:remove-internal-warn, r=dswij
Remove the `internal_warn` lint category `LINT_AUTHOR` and `DUMP_HIR` can be removed since their corresponding lint passes are only used for side effects The metadata collector lint can be made an `internal` lint since `clippy::internal` is set to deny when running the collector Also renames some internal lints/passes changelog: none
2 parents 0da4dab + 0580080 commit 392b255

File tree

10 files changed

+36
-53
lines changed

10 files changed

+36
-53
lines changed

clippy_dev/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ fn get_clap_config() -> ArgMatches {
199199
"cargo",
200200
"nursery",
201201
"internal",
202-
"internal_warn",
203202
]),
204203
Arg::new("type").long("type").help("What directory the lint belongs in"),
205204
Arg::new("msrv")

clippy_dev/src/update_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ impl Lint {
588588
.collect()
589589
}
590590

591-
/// Returns all internal lints (not `internal_warn` lints)
591+
/// Returns all internal lints
592592
#[must_use]
593593
fn internal_lints(lints: &[Self]) -> Vec<Self> {
594594
lints.iter().filter(|l| l.group == "internal").cloned().collect()

clippy_lints/src/declared_lints.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
66
#[cfg(feature = "internal")]
77
crate::utils::internal_lints::almost_standard_lint_formulation::ALMOST_STANDARD_LINT_FORMULATION_INFO,
88
#[cfg(feature = "internal")]
9-
crate::utils::internal_lints::clippy_lints_internal::CLIPPY_LINTS_INTERNAL_INFO,
10-
#[cfg(feature = "internal")]
119
crate::utils::internal_lints::collapsible_calls::COLLAPSIBLE_SPAN_LINT_CALLS_INFO,
1210
#[cfg(feature = "internal")]
1311
crate::utils::internal_lints::compiler_lint_functions::COMPILER_LINT_FUNCTIONS_INFO,
@@ -30,13 +28,17 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
3028
#[cfg(feature = "internal")]
3129
crate::utils::internal_lints::lint_without_lint_pass::MISSING_CLIPPY_VERSION_ATTRIBUTE_INFO,
3230
#[cfg(feature = "internal")]
31+
crate::utils::internal_lints::metadata_collector::METADATA_COLLECTOR_INFO,
32+
#[cfg(feature = "internal")]
3333
crate::utils::internal_lints::msrv_attr_impl::MISSING_MSRV_ATTR_IMPL_INFO,
3434
#[cfg(feature = "internal")]
3535
crate::utils::internal_lints::outer_expn_data_pass::OUTER_EXPN_EXPN_DATA_INFO,
3636
#[cfg(feature = "internal")]
3737
crate::utils::internal_lints::produce_ice::PRODUCE_ICE_INFO,
3838
#[cfg(feature = "internal")]
3939
crate::utils::internal_lints::unnecessary_def_path::UNNECESSARY_DEF_PATH_INFO,
40+
#[cfg(feature = "internal")]
41+
crate::utils::internal_lints::unsorted_clippy_utils_paths::UNSORTED_CLIPPY_UTILS_PATHS_INFO,
4042
crate::absolute_paths::ABSOLUTE_PATHS_INFO,
4143
crate::allow_attributes::ALLOW_ATTRIBUTES_INFO,
4244
crate::almost_complete_range::ALMOST_COMPLETE_RANGE_INFO,

clippy_lints/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,9 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
513513
// all the internal lints
514514
#[cfg(feature = "internal")]
515515
{
516-
store.register_early_pass(|| Box::new(utils::internal_lints::clippy_lints_internal::ClippyLintsInternal));
516+
store.register_early_pass(|| {
517+
Box::new(utils::internal_lints::unsorted_clippy_utils_paths::UnsortedClippyUtilsPaths)
518+
});
517519
store.register_early_pass(|| Box::new(utils::internal_lints::produce_ice::ProduceIce));
518520
store.register_late_pass(|_| Box::new(utils::internal_lints::collapsible_calls::CollapsibleCalls));
519521
store.register_late_pass(|_| {

clippy_lints/src/utils/author.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use rustc_hir::{
1010
ArrayLen, BindingAnnotation, Closure, ExprKind, FnRetTy, HirId, Lit, PatKind, QPath, StmtKind, TyKind,
1111
};
1212
use rustc_lint::{LateContext, LateLintPass, LintContext};
13-
use rustc_session::{declare_lint_pass, declare_tool_lint};
13+
use rustc_session::declare_lint_pass;
1414
use rustc_span::symbol::{Ident, Symbol};
1515
use std::cell::Cell;
1616
use std::fmt::{Display, Formatter, Write as _};
1717

18-
declare_clippy_lint! {
18+
declare_lint_pass!(
1919
/// ### What it does
2020
/// Generates clippy code that detects the offending pattern
2121
///
@@ -47,12 +47,8 @@ declare_clippy_lint! {
4747
/// // report your lint here
4848
/// }
4949
/// ```
50-
pub LINT_AUTHOR,
51-
internal_warn,
52-
"helper for writing lints"
53-
}
54-
55-
declare_lint_pass!(Author => [LINT_AUTHOR]);
50+
Author => []
51+
);
5652

5753
/// Writes a line of output with indentation added
5854
macro_rules! out {

clippy_lints/src/utils/dump_hir.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use clippy_utils::get_attr;
22
use hir::TraitItem;
33
use rustc_hir as hir;
44
use rustc_lint::{LateContext, LateLintPass, LintContext};
5-
use rustc_session::{declare_lint_pass, declare_tool_lint};
5+
use rustc_session::declare_lint_pass;
66

7-
declare_clippy_lint! {
7+
declare_lint_pass!(
88
/// ### What it does
99
/// It formats the attached node with `{:#?}` and writes the result to the
1010
/// standard output. This is intended for debugging.
@@ -19,12 +19,8 @@ declare_clippy_lint! {
1919
/// input as u64
2020
/// }
2121
/// ```
22-
pub DUMP_HIR,
23-
internal_warn,
24-
"helper to dump info about code"
25-
}
26-
27-
declare_lint_pass!(DumpHir => [DUMP_HIR]);
22+
DumpHir => []
23+
);
2824

2925
impl<'tcx> LateLintPass<'tcx> for DumpHir {
3026
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {

clippy_lints/src/utils/internal_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
pub mod almost_standard_lint_formulation;
2-
pub mod clippy_lints_internal;
32
pub mod collapsible_calls;
43
pub mod compiler_lint_functions;
54
pub mod if_chain_style;
@@ -11,3 +10,4 @@ pub mod msrv_attr_impl;
1110
pub mod outer_expn_data_pass;
1211
pub mod produce_ice;
1312
pub mod unnecessary_def_path;
13+
pub mod unsorted_clippy_utils_paths;

clippy_lints/src/utils/internal_lints/metadata_collector.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ use std::process::Command;
4040
const JSON_OUTPUT_FILE: &str = "../util/gh-pages/lints.json";
4141
/// This is the markdown output file of the lint collector.
4242
const MARKDOWN_OUTPUT_FILE: &str = "../book/src/lint_configuration.md";
43-
/// These lints are excluded from the export.
44-
const BLACK_LISTED_LINTS: &[&str] = &["lint_author", "dump_hir", "internal_metadata_collector"];
4543
/// These groups will be ignored by the lint group matcher. This is useful for collections like
4644
/// `clippy::all`
4745
const IGNORED_LINT_GROUPS: [&str; 1] = ["clippy::all"];
@@ -121,7 +119,7 @@ declare_clippy_lint! {
121119
/// ### Example output
122120
/// ```json,ignore
123121
/// {
124-
/// "id": "internal_metadata_collector",
122+
/// "id": "metadata_collector",
125123
/// "id_span": {
126124
/// "path": "clippy_lints/src/utils/internal_lints/metadata_collector.rs",
127125
/// "line": 1
@@ -131,12 +129,12 @@ declare_clippy_lint! {
131129
/// }
132130
/// ```
133131
#[clippy::version = "1.56.0"]
134-
pub INTERNAL_METADATA_COLLECTOR,
135-
internal_warn,
132+
pub METADATA_COLLECTOR,
133+
internal,
136134
"A busy bee collection metadata about lints"
137135
}
138136

139-
impl_lint_pass!(MetadataCollector => [INTERNAL_METADATA_COLLECTOR]);
137+
impl_lint_pass!(MetadataCollector => [METADATA_COLLECTOR]);
140138

141139
#[allow(clippy::module_name_repetitions)]
142140
#[derive(Debug, Clone)]
@@ -550,7 +548,6 @@ impl<'hir> LateLintPass<'hir> for MetadataCollector {
550548
if is_lint_ref_type(cx, ty);
551549
// disallow check
552550
let lint_name = sym_to_string(item.ident.name).to_ascii_lowercase();
553-
if !BLACK_LISTED_LINTS.contains(&lint_name.as_str());
554551
// metadata extraction
555552
if let Some((group, level)) = get_lint_group_and_level_or_lint(cx, &lint_name, item);
556553
if let Some(mut raw_docs) = extract_attr_docs_or_lint(cx, item);
@@ -575,7 +572,6 @@ impl<'hir> LateLintPass<'hir> for MetadataCollector {
575572
if is_deprecated_lint(cx, ty);
576573
// disallow check
577574
let lint_name = sym_to_string(item.ident.name).to_ascii_lowercase();
578-
if !BLACK_LISTED_LINTS.contains(&lint_name.as_str());
579575
// Metadata the little we can get from a deprecated lint
580576
if let Some(raw_docs) = extract_attr_docs_or_lint(cx, item);
581577
then {
@@ -831,7 +827,7 @@ fn collect_renames(lints: &mut Vec<LintMetadata>) {
831827
fn lint_collection_error_item(cx: &LateContext<'_>, item: &Item<'_>, message: &str) {
832828
span_lint(
833829
cx,
834-
INTERNAL_METADATA_COLLECTOR,
830+
METADATA_COLLECTOR,
835831
item.ident.span,
836832
&format!("metadata collection error for `{}`: {message}", item.ident.name),
837833
);

clippy_lints/src/utils/internal_lints/clippy_lints_internal.rs renamed to clippy_lints/src/utils/internal_lints/unsorted_clippy_utils_paths.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
55

66
declare_clippy_lint! {
77
/// ### What it does
8-
/// Checks for various things we like to keep tidy in clippy.
8+
/// Checks that [`clippy_utils::paths`] is sorted lexically
99
///
1010
/// ### Why is this bad?
1111
/// We like to pretend we're an example of tidy code.
1212
///
1313
/// ### Example
1414
/// Wrong ordering of the util::paths constants.
15-
pub CLIPPY_LINTS_INTERNAL,
15+
pub UNSORTED_CLIPPY_UTILS_PATHS,
1616
internal,
1717
"various things that will negatively affect your clippy experience"
1818
}
1919

20-
declare_lint_pass!(ClippyLintsInternal => [CLIPPY_LINTS_INTERNAL]);
20+
declare_lint_pass!(UnsortedClippyUtilsPaths => [UNSORTED_CLIPPY_UTILS_PATHS]);
2121

22-
impl EarlyLintPass for ClippyLintsInternal {
22+
impl EarlyLintPass for UnsortedClippyUtilsPaths {
2323
fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &Crate) {
2424
if let Some(utils) = krate.items.iter().find(|item| item.ident.name.as_str() == "utils") {
2525
if let ItemKind::Mod(_, ModKind::Loaded(ref items, ..)) = utils.kind {
@@ -32,7 +32,7 @@ impl EarlyLintPass for ClippyLintsInternal {
3232
if *last_name > *name {
3333
span_lint(
3434
cx,
35-
CLIPPY_LINTS_INTERNAL,
35+
UNSORTED_CLIPPY_UTILS_PATHS,
3636
item.span,
3737
"this constant should be before the previous constant due to lexical \
3838
ordering",

declare_clippy_lint/src/lib.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,28 +136,16 @@ pub fn declare_clippy_lint(input: TokenStream) -> TokenStream {
136136
"{}",
137137
match category.as_str() {
138138
"correctness" => "Deny",
139-
"style" | "suspicious" | "complexity" | "perf" | "internal_warn" => "Warn",
139+
"style" | "suspicious" | "complexity" | "perf" => "Warn",
140140
"pedantic" | "restriction" | "cargo" | "nursery" | "internal" => "Allow",
141141
_ => panic!("unknown category {category}"),
142142
},
143143
);
144144

145-
let info = if category == "internal_warn" {
146-
None
147-
} else {
148-
let info_name = format_ident!("{name}_INFO");
145+
let info_name = format_ident!("{name}_INFO");
149146

150-
(&mut category[0..1]).make_ascii_uppercase();
151-
let category_variant = format_ident!("{category}");
152-
153-
Some(quote! {
154-
pub(crate) static #info_name: &'static crate::LintInfo = &crate::LintInfo {
155-
lint: &#name,
156-
category: crate::LintCategory::#category_variant,
157-
explanation: #explanation,
158-
};
159-
})
160-
};
147+
(&mut category[0..1]).make_ascii_uppercase();
148+
let category_variant = format_ident!("{category}");
161149

162150
let output = quote! {
163151
declare_tool_lint! {
@@ -168,7 +156,11 @@ pub fn declare_clippy_lint(input: TokenStream) -> TokenStream {
168156
report_in_external_macro: true
169157
}
170158

171-
#info
159+
pub(crate) static #info_name: &'static crate::LintInfo = &crate::LintInfo {
160+
lint: &#name,
161+
category: crate::LintCategory::#category_variant,
162+
explanation: #explanation,
163+
};
172164
};
173165

174166
TokenStream::from(output)

0 commit comments

Comments
 (0)