Skip to content

Commit 7d3bb1d

Browse files
flip1995Mark-Simulacrum
authored andcommitted
Move only_used_in_recursion to nursery
1 parent 096a7ca commit 7d3bb1d

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

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

-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
237237
LintId::of(non_expressive_names::JUST_UNDERSCORES_AND_DIGITS),
238238
LintId::of(non_octal_unix_permissions::NON_OCTAL_UNIX_PERMISSIONS),
239239
LintId::of(octal_escapes::OCTAL_ESCAPES),
240-
LintId::of(only_used_in_recursion::ONLY_USED_IN_RECURSION),
241240
LintId::of(open_options::NONSENSICAL_OPEN_OPTIONS),
242241
LintId::of(option_env_unwrap::OPTION_ENV_UNWRAP),
243242
LintId::of(overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL),

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

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec!
6666
LintId::of(neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD),
6767
LintId::of(no_effect::NO_EFFECT),
6868
LintId::of(no_effect::UNNECESSARY_OPERATION),
69-
LintId::of(only_used_in_recursion::ONLY_USED_IN_RECURSION),
7069
LintId::of(overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL),
7170
LintId::of(partialeq_ne_impl::PARTIALEQ_NE_IMPL),
7271
LintId::of(precedence::PRECEDENCE),

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

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
2020
LintId::of(mutex_atomic::MUTEX_INTEGER),
2121
LintId::of(non_send_fields_in_send_ty::NON_SEND_FIELDS_IN_SEND_TY),
2222
LintId::of(nonstandard_macro_braces::NONSTANDARD_MACRO_BRACES),
23+
LintId::of(only_used_in_recursion::ONLY_USED_IN_RECURSION),
2324
LintId::of(option_if_let_else::OPTION_IF_LET_ELSE),
2425
LintId::of(path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE),
2526
LintId::of(redundant_pub_crate::REDUNDANT_PUB_CRATE),

src/tools/clippy/clippy_lints/src/only_used_in_recursion.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::VecDeque;
22

33
use clippy_utils::diagnostics::span_lint_and_sugg;
4+
use clippy_utils::is_lint_allowed;
45
use itertools::{izip, Itertools};
56
use rustc_ast::{walk_list, Label, Mutability};
67
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -33,6 +34,9 @@ declare_clippy_lint! {
3334
/// and the assigned variables are also only in recursion, it is useless.
3435
///
3536
/// ### Known problems
37+
/// Too many code paths in the linting code are currently untested and prone to produce false
38+
/// positives or are prone to have performance implications.
39+
///
3640
/// In some cases, this would not catch all useless arguments.
3741
///
3842
/// ```rust
@@ -85,7 +89,7 @@ declare_clippy_lint! {
8589
/// ```
8690
#[clippy::version = "1.60.0"]
8791
pub ONLY_USED_IN_RECURSION,
88-
complexity,
92+
nursery,
8993
"arguments that is only used in recursion can be removed"
9094
}
9195
declare_lint_pass!(OnlyUsedInRecursion => [ONLY_USED_IN_RECURSION]);
@@ -100,6 +104,9 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
100104
_: Span,
101105
id: HirId,
102106
) {
107+
if is_lint_allowed(cx, ONLY_USED_IN_RECURSION, id) {
108+
return;
109+
}
103110
if let FnKind::ItemFn(ident, ..) | FnKind::Method(ident, ..) = kind {
104111
let def_id = id.owner.to_def_id();
105112
let data = cx.tcx.def_path(def_id).data;

0 commit comments

Comments
 (0)