]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/ptr_offset_with_cast.rs
Auto merge of #9148 - arieluy:then_some_unwrap_or, r=Jarcho
[rust.git] / clippy_lints / src / ptr_offset_with_cast.rs
index f1975056ddc9ba40751c82161bdc96f14cafc0fd..b907f38afbb92f96dfb27efe3659872e239bac34 100644 (file)
@@ -38,6 +38,7 @@
     ///     ptr.add(offset);
     /// }
     /// ```
+    #[clippy::version = "1.30.0"]
     pub PTR_OFFSET_WITH_CAST,
     complexity,
     "unneeded pointer offset cast"
@@ -92,13 +93,13 @@ fn expr_as_ptr_offset_call<'tcx>(
     cx: &LateContext<'tcx>,
     expr: &'tcx Expr<'_>,
 ) -> Option<(&'tcx Expr<'tcx>, &'tcx Expr<'tcx>, Method)> {
-    if let ExprKind::MethodCall(path_segment, _, args, _) = expr.kind {
-        if is_expr_ty_raw_ptr(cx, &args[0]) {
+    if let ExprKind::MethodCall(path_segment, [arg_0, arg_1, ..], _) = &expr.kind {
+        if is_expr_ty_raw_ptr(cx, arg_0) {
             if path_segment.ident.name == sym::offset {
-                return Some((&args[0], &args[1], Method::Offset));
+                return Some((arg_0, arg_1, Method::Offset));
             }
             if path_segment.ident.name == sym!(wrapping_offset) {
-                return Some((&args[0], &args[1], Method::WrappingOffset));
+                return Some((arg_0, arg_1, Method::WrappingOffset));
             }
         }
     }