]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/needless_update.rs
Auto merge of #9148 - arieluy:then_some_unwrap_or, r=Jarcho
[rust.git] / clippy_lints / src / needless_update.rs
index ed315efaa2fa7c546de3a7fabce42dc2997a80f5..0bd29d1776b28e714dc2438f7a675fa632887fca 100644 (file)
     /// #     z: i32,
     /// # }
     /// # let zero_point = Point { x: 0, y: 0, z: 0 };
-    ///
-    /// // Bad
     /// Point {
     ///     x: 1,
     ///     y: 1,
     ///     z: 1,
     ///     ..zero_point
     /// };
+    /// ```
     ///
-    /// // Ok
+    /// Use instead:
+    /// ```rust,ignore
+    /// // Missing field `z`
     /// Point {
     ///     x: 1,
     ///     y: 1,
@@ -54,7 +55,7 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
             let ty = cx.typeck_results().expr_ty(expr);
             if let ty::Adt(def, _) = ty.kind() {
                 if fields.len() == def.non_enum_variant().fields.len()
-                    && !def.variants[0_usize.into()].is_field_list_non_exhaustive()
+                    && !def.variant(0_usize.into()).is_field_list_non_exhaustive()
                 {
                     span_lint(
                         cx,