about summary refs log tree commit diff
path: root/clippy_lints/src/methods
diff options
context:
space:
mode:
authorSamuel Moelius <sam@moeli.us>2024-11-26 06:09:29 -0500
committerSamuel Moelius <sam@moeli.us>2024-12-26 19:36:58 -0500
commit8a38bcc39083a2c73c2b7f27870d6bef85756f52 (patch)
tree833fe27fa609e757565598a6bc87dfda2c290586 /clippy_lints/src/methods
parentb8e569e9c006100be58155d037735561fe600faf (diff)
downloadrust-8a38bcc39083a2c73c2b7f27870d6bef85756f52.tar.gz
rust-8a38bcc39083a2c73c2b7f27870d6bef85756f52.zip
Make "all fields are shorthand" requirement configurable
Handle field attributes in suggestions

Fix adjacent code

Address review comments

https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1861352124

Address all review comments but one

This comment is not yet addressed: https://github.com/rust-lang/rust-clippy/pull/13737#discussion_r1874544907

`initializer_suggestions` -> `lint_inconsistent_struct_field_initializers`
Diffstat (limited to 'clippy_lints/src/methods')
-rw-r--r--clippy_lints/src/methods/needless_collect.rs10
-rw-r--r--clippy_lints/src/methods/str_splitn.rs2
-rw-r--r--clippy_lints/src/methods/unnecessary_fold.rs8
3 files changed, 10 insertions, 10 deletions
diff --git a/clippy_lints/src/methods/needless_collect.rs b/clippy_lints/src/methods/needless_collect.rs
index ea4984f83ad..2780c3f8af5 100644
--- a/clippy_lints/src/methods/needless_collect.rs
+++ b/clippy_lints/src/methods/needless_collect.rs
@@ -470,14 +470,14 @@ fn detect_iter_and_into_iters<'tcx: 'a, 'a>(
     captured_ids: HirIdSet,
 ) -> Option<Vec<IterFunction>> {
     let mut visitor = IterFunctionVisitor {
-        uses: Vec::new(),
-        target: id,
-        seen_other: false,
-        cx,
-        current_mutably_captured_ids: HirIdSet::default(),
         illegal_mutable_capture_ids: captured_ids,
+        current_mutably_captured_ids: HirIdSet::default(),
+        cx,
+        uses: Vec::new(),
         hir_id_uses_map: FxHashMap::default(),
         current_statement_hir_id: None,
+        seen_other: false,
+        target: id,
     };
     visitor.visit_block(block);
     if visitor.seen_other {
diff --git a/clippy_lints/src/methods/str_splitn.rs b/clippy_lints/src/methods/str_splitn.rs
index c6d4ef5911e..8a99974394c 100644
--- a/clippy_lints/src/methods/str_splitn.rs
+++ b/clippy_lints/src/methods/str_splitn.rs
@@ -297,8 +297,8 @@ fn parse_iter_usage<'tcx>(
                     {
                         Some(IterUsage {
                             kind: IterUsageKind::NextTuple,
-                            span: e.span,
                             unwrap_kind: None,
+                            span: e.span,
                         })
                     } else {
                         None
diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs
index b5d8972d7aa..c27d1fb4903 100644
--- a/clippy_lints/src/methods/unnecessary_fold.rs
+++ b/clippy_lints/src/methods/unnecessary_fold.rs
@@ -124,30 +124,30 @@ pub(super) fn check(
         match lit.node {
             ast::LitKind::Bool(false) => {
                 check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Or, Replacement {
+                    method_name: "any",
                     has_args: true,
                     has_generic_return: false,
-                    method_name: "any",
                 });
             },
             ast::LitKind::Bool(true) => {
                 check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::And, Replacement {
+                    method_name: "all",
                     has_args: true,
                     has_generic_return: false,
-                    method_name: "all",
                 });
             },
             ast::LitKind::Int(Pu128(0), _) => {
                 check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Add, Replacement {
+                    method_name: "sum",
                     has_args: false,
                     has_generic_return: needs_turbofish(cx, expr),
-                    method_name: "sum",
                 });
             },
             ast::LitKind::Int(Pu128(1), _) => {
                 check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Mul, Replacement {
+                    method_name: "product",
                     has_args: false,
                     has_generic_return: needs_turbofish(cx, expr),
-                    method_name: "product",
                 });
             },
             _ => (),