about summary refs log tree commit diff
path: root/clippy_lints/src/inconsistent_struct_constructor.rs
diff options
context:
space:
mode:
authorPhilipp Krones <hello@philkrones.com>2024-07-25 18:29:17 +0200
committerPhilipp Krones <hello@philkrones.com>2024-07-25 18:29:17 +0200
commit4e6851e50bde42cef280076aa48035871bfe9520 (patch)
tree2ef7c556ab708bcf7ffd666fcfa76ccfa8378de8 /clippy_lints/src/inconsistent_struct_constructor.rs
parent6d674685ae4e9156dbb6ecd3aa38d87864ecab3e (diff)
downloadrust-4e6851e50bde42cef280076aa48035871bfe9520.tar.gz
rust-4e6851e50bde42cef280076aa48035871bfe9520.zip
Merge commit '37f4fbb92913586b73a35772efd00eccd1cbbe13' into clippy-subtree-update
Diffstat (limited to 'clippy_lints/src/inconsistent_struct_constructor.rs')
-rw-r--r--clippy_lints/src/inconsistent_struct_constructor.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/clippy_lints/src/inconsistent_struct_constructor.rs b/clippy_lints/src/inconsistent_struct_constructor.rs
index 1075975f0a2..5b0aadf35c6 100644
--- a/clippy_lints/src/inconsistent_struct_constructor.rs
+++ b/clippy_lints/src/inconsistent_struct_constructor.rs
@@ -65,13 +65,13 @@ declare_lint_pass!(InconsistentStructConstructor => [INCONSISTENT_STRUCT_CONSTRU
 
 impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
     fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
-        if !expr.span.from_expansion()
-            && let ExprKind::Struct(qpath, fields, base) = expr.kind
+        if let ExprKind::Struct(qpath, fields, base) = expr.kind
+            && fields.iter().all(|f| f.is_shorthand)
+            && !expr.span.from_expansion()
             && let ty = cx.typeck_results().expr_ty(expr)
             && let Some(adt_def) = ty.ty_adt_def()
             && adt_def.is_struct()
             && let Some(variant) = adt_def.variants().iter().next()
-            && fields.iter().all(|f| f.is_shorthand)
         {
             let mut def_order_map = FxHashMap::default();
             for (idx, field) in variant.fields.iter().enumerate() {