diff options
| author | Philipp Krones <hello@philkrones.com> | 2024-07-25 18:09:52 +0200 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2024-07-25 18:23:27 +0200 |
| commit | 9f53fc32cfb62724d95de44779259ce4e24bc085 (patch) | |
| tree | df5069c84c1a281c78b72e8935a9664b3110f66a /clippy_lints/src/inconsistent_struct_constructor.rs | |
| parent | 6d674685ae4e9156dbb6ecd3aa38d87864ecab3e (diff) | |
| parent | df0cb6c51ee798264586ee9144466cf003d68181 (diff) | |
Merge remote-tracking branch 'upstream/master' into rustup
Diffstat (limited to 'clippy_lints/src/inconsistent_struct_constructor.rs')
| -rw-r--r-- | clippy_lints/src/inconsistent_struct_constructor.rs | 6 |
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() { |
