add test for closures

This commit is contained in:
Centri3 2023-06-14 07:16:56 -05:00
parent 07dbcbda12
commit a8605269bd
4 changed files with 63 additions and 22 deletions

View file

@ -88,14 +88,14 @@ impl<'tcx> LateLintPass<'tcx> for SingleCallFn {
cx.tcx.hir().visit_all_item_likes_in_crate(&mut v);
for usage in self.def_id_to_usage.values() {
let fn_span = usage.0;
if let [usage] = *usage.1 {
let single_call_fn_span = usage.0;
if let [caller_span] = *usage.1 {
span_lint_and_help(
cx,
SINGLE_CALL_FN,
fn_span,
single_call_fn_span,
"this function is only used once",
Some(usage),
Some(caller_span),
"used here",
);
}

View file

@ -289,7 +289,7 @@ define_Conf! {
/// arithmetic-side-effects-allowed-unary = ["SomeType", "AnotherType"]
/// ```
(arithmetic_side_effects_allowed_unary: rustc_data_structures::fx::FxHashSet<String> = <_>::default()),
/// Lint: ENUM_VARIANT_NAMES, LARGE_TYPES_PASSED_BY_VALUE, TRIVIALLY_COPY_PASS_BY_REF, UNNECESSARY_WRAPS, UNUSED_SELF, UPPER_CASE_ACRONYMS, WRONG_SELF_CONVENTION, BOX_COLLECTION, REDUNDANT_ALLOCATION, RC_BUFFER, VEC_BOX, OPTION_OPTION, LINKEDLIST, RC_MUTEX, UNNECESSARY_BOX_RETURNS.
/// Lint: ENUM_VARIANT_NAMES, LARGE_TYPES_PASSED_BY_VALUE, TRIVIALLY_COPY_PASS_BY_REF, UNNECESSARY_WRAPS, UNUSED_SELF, UPPER_CASE_ACRONYMS, WRONG_SELF_CONVENTION, BOX_COLLECTION, REDUNDANT_ALLOCATION, RC_BUFFER, VEC_BOX, OPTION_OPTION, LINKEDLIST, RC_MUTEX, UNNECESSARY_BOX_RETURNS, SINGLE_CALL_FN.
///
/// Suppress lints whenever the suggested change would cause breakage for other crates.
(avoid_breaking_exported_api: bool = true),