|
8 | 8 | //! Thank you!
|
9 | 9 | //! ~The `INTERNAL_METADATA_COLLECTOR` lint
|
10 | 10 |
|
11 |
| -use rustc_data_structures::fx::FxHashSet; |
12 | 11 | use rustc_errors::{Applicability, Diag, DiagMessage, MultiSpan, SubdiagMessage};
|
13 | 12 | #[cfg(debug_assertions)]
|
14 | 13 | use rustc_errors::{EmissionGuarantee, SubstitutionPart, Suggestions};
|
15 | 14 | use rustc_hir::HirId;
|
16 | 15 | use rustc_lint::{LateContext, Lint, LintContext};
|
17 | 16 | use rustc_span::Span;
|
18 | 17 | use std::env;
|
19 |
| -use std::sync::OnceLock; |
20 |
| - |
21 |
| -pub static DISABLED: OnceLock<FxHashSet<&'static str>> = OnceLock::new(); |
22 |
| - |
23 |
| -#[allow(clippy::implicit_hasher)] |
24 |
| -pub fn set_disabled(disabled: FxHashSet<&'static str>) { |
25 |
| - DISABLED |
26 |
| - .set(disabled) |
27 |
| - .unwrap_or_else(|_| panic!("`set_disabled` was already called")); |
28 |
| -} |
29 |
| - |
30 |
| -fn is_disabled(lint: &Lint) -> bool { |
31 |
| - DISABLED.get().is_some_and(|disabled| { |
32 |
| - let name = lint.name_lower(); |
33 |
| - disabled.contains(name.strip_prefix("clippy::").unwrap_or(&name)) |
34 |
| - }) |
35 |
| -} |
36 | 18 |
|
37 | 19 | fn docs_link(diag: &mut Diag<'_, ()>, lint: &'static Lint) {
|
38 | 20 | if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err()
|
@@ -122,9 +104,6 @@ fn validate_diag(diag: &Diag<'_, impl EmissionGuarantee>) {
|
122 | 104 | /// ```
|
123 | 105 | #[track_caller]
|
124 | 106 | pub fn span_lint<T: LintContext>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
|
125 |
| - if is_disabled(lint) { |
126 |
| - return; |
127 |
| - } |
128 | 107 | #[expect(clippy::disallowed_methods)]
|
129 | 108 | cx.span_lint(lint, sp, |diag| {
|
130 | 109 | diag.primary_message(msg);
|
@@ -178,9 +157,6 @@ pub fn span_lint_and_help<T: LintContext>(
|
178 | 157 | help_span: Option<Span>,
|
179 | 158 | help: impl Into<SubdiagMessage>,
|
180 | 159 | ) {
|
181 |
| - if is_disabled(lint) { |
182 |
| - return; |
183 |
| - } |
184 | 160 | #[expect(clippy::disallowed_methods)]
|
185 | 161 | cx.span_lint(lint, span, |diag| {
|
186 | 162 | diag.primary_message(msg);
|
@@ -242,9 +218,6 @@ pub fn span_lint_and_note<T: LintContext>(
|
242 | 218 | note_span: Option<Span>,
|
243 | 219 | note: impl Into<SubdiagMessage>,
|
244 | 220 | ) {
|
245 |
| - if is_disabled(lint) { |
246 |
| - return; |
247 |
| - } |
248 | 221 | #[expect(clippy::disallowed_methods)]
|
249 | 222 | cx.span_lint(lint, span, |diag| {
|
250 | 223 | diag.primary_message(msg);
|
@@ -286,9 +259,6 @@ where
|
286 | 259 | M: Into<DiagMessage>,
|
287 | 260 | F: FnOnce(&mut Diag<'_, ()>),
|
288 | 261 | {
|
289 |
| - if is_disabled(lint) { |
290 |
| - return; |
291 |
| - } |
292 | 262 | #[expect(clippy::disallowed_methods)]
|
293 | 263 | cx.span_lint(lint, sp, |diag| {
|
294 | 264 | diag.primary_message(msg);
|
@@ -326,9 +296,6 @@ where
|
326 | 296 | /// the `#[allow]` will work.
|
327 | 297 | #[track_caller]
|
328 | 298 | pub fn span_lint_hir(cx: &LateContext<'_>, lint: &'static Lint, hir_id: HirId, sp: Span, msg: impl Into<DiagMessage>) {
|
329 |
| - if is_disabled(lint) { |
330 |
| - return; |
331 |
| - } |
332 | 299 | #[expect(clippy::disallowed_methods)]
|
333 | 300 | cx.tcx.node_span_lint(lint, hir_id, sp, |diag| {
|
334 | 301 | diag.primary_message(msg);
|
@@ -372,9 +339,6 @@ pub fn span_lint_hir_and_then(
|
372 | 339 | msg: impl Into<DiagMessage>,
|
373 | 340 | f: impl FnOnce(&mut Diag<'_, ()>),
|
374 | 341 | ) {
|
375 |
| - if is_disabled(lint) { |
376 |
| - return; |
377 |
| - } |
378 | 342 | #[expect(clippy::disallowed_methods)]
|
379 | 343 | cx.tcx.node_span_lint(lint, hir_id, sp, |diag| {
|
380 | 344 | diag.primary_message(msg);
|
|
0 commit comments