Skip to content

Commit 13728b8

Browse files
committed
Deprecate unknown_clippy_lints
This is now handled by unknown_lints
1 parent 5e3df42 commit 13728b8

File tree

6 files changed

+50
-91
lines changed

6 files changed

+50
-91
lines changed

src/tools/clippy/clippy_lints/src/attrs.rs

+2-70
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ use rustc_errors::Applicability;
1010
use rustc_hir::{
1111
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind,
1212
};
13-
use rustc_lint::{CheckLintNameResult, EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
13+
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
1414
use rustc_middle::lint::in_external_macro;
1515
use rustc_middle::ty;
1616
use rustc_session::{declare_lint_pass, declare_tool_lint};
17-
use rustc_span::lev_distance::find_best_match_for_name;
1817
use rustc_span::source_map::Span;
1918
use rustc_span::sym;
2019
use rustc_span::symbol::{Symbol, SymbolStr};
@@ -156,33 +155,6 @@ declare_clippy_lint! {
156155
"empty line after outer attribute"
157156
}
158157

159-
declare_clippy_lint! {
160-
/// **What it does:** Checks for `allow`/`warn`/`deny`/`forbid` attributes with scoped clippy
161-
/// lints and if those lints exist in clippy. If there is an uppercase letter in the lint name
162-
/// (not the tool name) and a lowercase version of this lint exists, it will suggest to lowercase
163-
/// the lint name.
164-
///
165-
/// **Why is this bad?** A lint attribute with a mistyped lint name won't have an effect.
166-
///
167-
/// **Known problems:** None.
168-
///
169-
/// **Example:**
170-
/// Bad:
171-
/// ```rust
172-
/// #![warn(if_not_els)]
173-
/// #![deny(clippy::All)]
174-
/// ```
175-
///
176-
/// Good:
177-
/// ```rust
178-
/// #![warn(if_not_else)]
179-
/// #![deny(clippy::all)]
180-
/// ```
181-
pub UNKNOWN_CLIPPY_LINTS,
182-
style,
183-
"unknown_lints for scoped Clippy lints"
184-
}
185-
186158
declare_clippy_lint! {
187159
/// **What it does:** Checks for `warn`/`deny`/`forbid` attributes targeting the whole clippy::restriction category.
188160
///
@@ -272,7 +244,6 @@ declare_lint_pass!(Attributes => [
272244
INLINE_ALWAYS,
273245
DEPRECATED_SEMVER,
274246
USELESS_ATTRIBUTE,
275-
UNKNOWN_CLIPPY_LINTS,
276247
BLANKET_CLIPPY_RESTRICTION_LINTS,
277248
]);
278249

@@ -409,48 +380,9 @@ fn extract_clippy_lint(lint: &NestedMetaItem) -> Option<SymbolStr> {
409380
}
410381

411382
fn check_clippy_lint_names(cx: &LateContext<'_>, ident: &str, items: &[NestedMetaItem]) {
412-
let lint_store = cx.lints();
413383
for lint in items {
414384
if let Some(lint_name) = extract_clippy_lint(lint) {
415-
if let CheckLintNameResult::Tool(Err((None, _))) = lint_store.check_lint_name(&lint_name, Some(sym::clippy))
416-
{
417-
span_lint_and_then(
418-
cx,
419-
UNKNOWN_CLIPPY_LINTS,
420-
lint.span(),
421-
&format!("unknown clippy lint: clippy::{}", lint_name),
422-
|diag| {
423-
let name_lower = lint_name.to_lowercase();
424-
let symbols = lint_store
425-
.get_lints()
426-
.iter()
427-
.map(|l| Symbol::intern(&l.name_lower()))
428-
.collect::<Vec<_>>();
429-
let sugg = find_best_match_for_name(
430-
&symbols,
431-
Symbol::intern(&format!("clippy::{}", name_lower)),
432-
None,
433-
);
434-
if lint_name.chars().any(char::is_uppercase)
435-
&& lint_store.find_lints(&format!("clippy::{}", name_lower)).is_ok()
436-
{
437-
diag.span_suggestion(
438-
lint.span(),
439-
"lowercase the lint name",
440-
format!("clippy::{}", name_lower),
441-
Applicability::MachineApplicable,
442-
);
443-
} else if let Some(sugg) = sugg {
444-
diag.span_suggestion(
445-
lint.span(),
446-
"did you mean",
447-
sugg.to_string(),
448-
Applicability::MachineApplicable,
449-
);
450-
}
451-
},
452-
);
453-
} else if lint_name == "restriction" && ident != "allow" {
385+
if lint_name == "restriction" && ident != "allow" {
454386
span_lint_and_help(
455387
cx,
456388
BLANKET_CLIPPY_RESTRICTION_LINTS,

src/tools/clippy/clippy_lints/src/deprecated_lints.rs

+13
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@ declare_deprecated_lint! {
163163
}
164164

165165
declare_deprecated_lint! {
166+
/// **What it does:** Nothing. This lint has been deprecated.
167+
///
168+
/// **Deprecation reason:** This lint has been uplifted to rustc and is now called
169+
/// `panic_fmt`.
166170
pub PANIC_PARAMS,
167171
"this lint has been uplifted to rustc and is now called `panic_fmt`"
168172
}
173+
174+
declare_deprecated_lint! {
175+
/// **What it does:** Nothing. This lint has been deprecated.
176+
///
177+
/// **Deprecation reason:** This lint has been integrated into the `unknown_lints`
178+
/// rustc lint.
179+
pub UNKNOWN_CLIPPY_LINTS,
180+
"this lint has been integrated into the `unknown_lints` rustc lint"
181+
}

src/tools/clippy/clippy_lints/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
500500
"clippy::panic_params",
501501
"this lint has been uplifted to rustc and is now called `panic_fmt`",
502502
);
503+
store.register_removed(
504+
"clippy::unknown_clippy_lints",
505+
"this lint has been integrated into the `unknown_lints` rustc lint",
506+
);
503507
// end deprecated lints, do not remove this comment, it’s used in `update_lints`
504508

505509
// begin register lints, do not remove this comment, it’s used in `update_lints`
@@ -541,7 +545,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
541545
&attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
542546
&attrs::INLINE_ALWAYS,
543547
&attrs::MISMATCHED_TARGET_OS,
544-
&attrs::UNKNOWN_CLIPPY_LINTS,
545548
&attrs::USELESS_ATTRIBUTE,
546549
&await_holding_invalid::AWAIT_HOLDING_LOCK,
547550
&await_holding_invalid::AWAIT_HOLDING_REFCELL_REF,
@@ -1375,7 +1378,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13751378
LintId::of(&attrs::DEPRECATED_CFG_ATTR),
13761379
LintId::of(&attrs::DEPRECATED_SEMVER),
13771380
LintId::of(&attrs::MISMATCHED_TARGET_OS),
1378-
LintId::of(&attrs::UNKNOWN_CLIPPY_LINTS),
13791381
LintId::of(&attrs::USELESS_ATTRIBUTE),
13801382
LintId::of(&bit_mask::BAD_BIT_MASK),
13811383
LintId::of(&bit_mask::INEFFECTIVE_BIT_MASK),
@@ -1650,7 +1652,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
16501652
LintId::of(&assertions_on_constants::ASSERTIONS_ON_CONSTANTS),
16511653
LintId::of(&assign_ops::ASSIGN_OP_PATTERN),
16521654
LintId::of(&attrs::BLANKET_CLIPPY_RESTRICTION_LINTS),
1653-
LintId::of(&attrs::UNKNOWN_CLIPPY_LINTS),
16541655
LintId::of(&blacklisted_name::BLACKLISTED_NAME),
16551656
LintId::of(&blocks_in_if_conditions::BLOCKS_IN_IF_CONDITIONS),
16561657
LintId::of(&collapsible_if::COLLAPSIBLE_IF),

src/tools/clippy/tests/ui/deprecated.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
#[warn(clippy::drop_bounds)]
1010
#[warn(clippy::temporary_cstring_as_ptr)]
1111
#[warn(clippy::panic_params)]
12+
#[warn(clippy::unknown_clippy_lints)]
1213

1314
fn main() {}

src/tools/clippy/tests/ui/deprecated.stderr

+7-1
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,17 @@ error: lint `clippy::panic_params` has been removed: `this lint has been uplifte
6666
LL | #[warn(clippy::panic_params)]
6767
| ^^^^^^^^^^^^^^^^^^^^
6868

69+
error: lint `clippy::unknown_clippy_lints` has been removed: `this lint has been integrated into the `unknown_lints` rustc lint`
70+
--> $DIR/deprecated.rs:12:8
71+
|
72+
LL | #[warn(clippy::unknown_clippy_lints)]
73+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74+
6975
error: lint `clippy::unstable_as_slice` has been removed: ``Vec::as_slice` has been stabilized in 1.7`
7076
--> $DIR/deprecated.rs:1:8
7177
|
7278
LL | #[warn(clippy::unstable_as_slice)]
7379
| ^^^^^^^^^^^^^^^^^^^^^^^^^
7480

75-
error: aborting due to 12 previous errors
81+
error: aborting due to 13 previous errors
7682

Original file line numberDiff line numberDiff line change
@@ -1,52 +1,58 @@
1-
error: unknown clippy lint: clippy::if_not_els
1+
error: unknown lint: `clippy::All`
2+
--> $DIR/unknown_clippy_lints.rs:5:10
3+
|
4+
LL | #![allow(clippy::All)]
5+
| ^^^^^^^^^^^ help: did you mean: `clippy::all`
6+
|
7+
= note: `-D unknown-lints` implied by `-D warnings`
8+
9+
error: unknown lint: `clippy::CMP_NAN`
10+
--> $DIR/unknown_clippy_lints.rs:6:9
11+
|
12+
LL | #![warn(clippy::CMP_NAN)]
13+
| ^^^^^^^^^^^^^^^ help: did you mean: `clippy::cmp_nan`
14+
15+
error: unknown lint: `clippy::if_not_els`
216
--> $DIR/unknown_clippy_lints.rs:9:8
317
|
418
LL | #[warn(clippy::if_not_els)]
519
| ^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::if_not_else`
6-
|
7-
= note: `-D clippy::unknown-clippy-lints` implied by `-D warnings`
820

9-
error: unknown clippy lint: clippy::UNNecsaRy_cAst
21+
error: unknown lint: `clippy::UNNecsaRy_cAst`
1022
--> $DIR/unknown_clippy_lints.rs:10:8
1123
|
1224
LL | #[warn(clippy::UNNecsaRy_cAst)]
1325
| ^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::unnecessary_cast`
1426

15-
error: unknown clippy lint: clippy::useles_transute
27+
error: unknown lint: `clippy::useles_transute`
1628
--> $DIR/unknown_clippy_lints.rs:11:8
1729
|
1830
LL | #[warn(clippy::useles_transute)]
1931
| ^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::useless_transmute`
2032

21-
error: unknown clippy lint: clippy::dead_cod
33+
error: unknown lint: `clippy::dead_cod`
2234
--> $DIR/unknown_clippy_lints.rs:13:8
2335
|
2436
LL | #[warn(clippy::dead_cod)]
2537
| ^^^^^^^^^^^^^^^^ help: did you mean: `clippy::drop_copy`
2638

27-
error: unknown clippy lint: clippy::unused_colle
39+
error: unknown lint: `clippy::unused_colle`
2840
--> $DIR/unknown_clippy_lints.rs:15:8
2941
|
3042
LL | #[warn(clippy::unused_colle)]
3143
| ^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::unused_self`
3244

33-
error: unknown clippy lint: clippy::const_static_lifetim
45+
error: unknown lint: `clippy::const_static_lifetim`
3446
--> $DIR/unknown_clippy_lints.rs:17:8
3547
|
3648
LL | #[warn(clippy::const_static_lifetim)]
3749
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `clippy::redundant_static_lifetimes`
3850

39-
error: unknown clippy lint: clippy::All
51+
error: unknown lint: `clippy::All`
4052
--> $DIR/unknown_clippy_lints.rs:5:10
4153
|
4254
LL | #![allow(clippy::All)]
43-
| ^^^^^^^^^^^ help: lowercase the lint name: `clippy::all`
44-
45-
error: unknown clippy lint: clippy::CMP_NAN
46-
--> $DIR/unknown_clippy_lints.rs:6:9
47-
|
48-
LL | #![warn(clippy::CMP_NAN)]
49-
| ^^^^^^^^^^^^^^^ help: lowercase the lint name: `clippy::cmp_nan`
55+
| ^^^^^^^^^^^ help: did you mean: `clippy::all`
5056

51-
error: aborting due to 8 previous errors
57+
error: aborting due to 9 previous errors
5258

0 commit comments

Comments
 (0)