Skip to content

Commit 3a54117

Browse files
committed
Auto merge of #8804 - Jarcho:in_recursion, r=Alexendoo
Rework `only_used_in_recursion` fixes #8782 fixes #8629 fixes #8560 fixes #8556 This is a complete rewrite of the lint. This loses some capabilities of the old implementation. Namely the ability to track through tuple and slice patterns, as well as the ability to trace through assignments. The two reported bugs are fixed with this. One was caused by using the name of the method rather than resolving to the `DefId` of the called method. The second was cause by using the existence of a cycle in the dependency graph to determine whether the parameter was used in recursion even though there were other ways to create a cycle in the graph. Implementation wise this switches from using a visitor to walking up the tree from every use of each parameter until it has been determined the parameter is used for something other than recursion. This is likely to perform better as it avoids walking the entire function a second time, and it is unlikely to walk up the HIR tree very much. Some cases would perform worse though. cc `@buttercrab` changelog: Scale back `only_used_in_recursion` to fix false positives changelog: Move `only_used_in_recursion` back to `complexity`
2 parents 3e594de + 39f4bee commit 3a54117

10 files changed

+664
-663
lines changed

clippy_lints/src/lib.register_all.rs

+1
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
252252
LintId::of(non_expressive_names::JUST_UNDERSCORES_AND_DIGITS),
253253
LintId::of(non_octal_unix_permissions::NON_OCTAL_UNIX_PERMISSIONS),
254254
LintId::of(octal_escapes::OCTAL_ESCAPES),
255+
LintId::of(only_used_in_recursion::ONLY_USED_IN_RECURSION),
255256
LintId::of(operators::ABSURD_EXTREME_COMPARISONS),
256257
LintId::of(operators::ASSIGN_OP_PATTERN),
257258
LintId::of(operators::BAD_BIT_MASK),

clippy_lints/src/lib.register_complexity.rs

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ store.register_group(true, "clippy::complexity", Some("clippy_complexity"), vec!
7272
LintId::of(neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD),
7373
LintId::of(no_effect::NO_EFFECT),
7474
LintId::of(no_effect::UNNECESSARY_OPERATION),
75+
LintId::of(only_used_in_recursion::ONLY_USED_IN_RECURSION),
7576
LintId::of(operators::DOUBLE_COMPARISONS),
7677
LintId::of(operators::DURATION_SUBSEC),
7778
LintId::of(operators::IDENTITY_OP),

clippy_lints/src/lib.register_nursery.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
2424
LintId::of(mutex_atomic::MUTEX_INTEGER),
2525
LintId::of(non_send_fields_in_send_ty::NON_SEND_FIELDS_IN_SEND_TY),
2626
LintId::of(nonstandard_macro_braces::NONSTANDARD_MACRO_BRACES),
27-
LintId::of(only_used_in_recursion::ONLY_USED_IN_RECURSION),
2827
LintId::of(option_if_let_else::OPTION_IF_LET_ELSE),
2928
LintId::of(redundant_pub_crate::REDUNDANT_PUB_CRATE),
3029
LintId::of(regex::TRIVIAL_REGEX),

clippy_lints/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
860860
store.register_late_pass(move || Box::new(manual_bits::ManualBits::new(msrv)));
861861
store.register_late_pass(|| Box::new(default_union_representation::DefaultUnionRepresentation));
862862
store.register_early_pass(|| Box::new(doc_link_with_quotes::DocLinkWithQuotes));
863-
store.register_late_pass(|| Box::new(only_used_in_recursion::OnlyUsedInRecursion));
863+
store.register_late_pass(|| Box::new(only_used_in_recursion::OnlyUsedInRecursion::default()));
864864
let allow_dbg_in_tests = conf.allow_dbg_in_tests;
865865
store.register_late_pass(move || Box::new(dbg_macro::DbgMacro::new(allow_dbg_in_tests)));
866866
let cargo_ignore_publish = conf.cargo_ignore_publish;

0 commit comments

Comments
 (0)