From 476baeb37dad577bf28b76f0e03c8e50dcd398c4 Mon Sep 17 00:00:00 2001 From: GHA CI Date: Sat, 14 Dec 2024 05:31:32 +0000 Subject: [PATCH] Automatic deploy to GitHub Pages: bfb87b9d3448d87c8dd8d833287d817a78292f47 --- master/index.html | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/master/index.html b/master/index.html index 9474c884ef5d..e15356859d26 100644 --- a/master/index.html +++ b/master/index.html @@ -4450,35 +4450,40 @@

Configuration

Applicability: MaybeIncorrect(?)
Added in: 1.59.0

What it does

-

Checks for usage of indexing or slicing. Arrays are special cases, this lint -does report on arrays if we can tell that slicing operations are in bounds and does not -lint on constant usize indexing on arrays because that is handled by rustc’s const_err lint.

+

Checks for usage of indexing or slicing that may panic at runtime.

+

This lint does not report on indexing or slicing operations +that always panic, clippy’s out_of_bound_indexing already +handles those cases.

Why restrict this?

-

To avoid implicit panics from indexing and slicing. -There are “checked” alternatives which do not panic, and can be used with unwrap() to make +

To avoid implicit panics from indexing and slicing.

+

There are “checked” alternatives which do not panic, and can be used with unwrap() to make an explicit panic when it is desired.

Limitations

This lint does not check for the usage of indexing or slicing on strings. These are covered by the more specific string_slice lint.

Example

// Vector
-let x = vec![0; 5];
+let x = vec![0, 1, 2, 3];
 
 x[2];
+x[100];
 &x[2..100];
 
 // Array
 let y = [0, 1, 2, 3];
 
-&y[10..100];
-&y[10..];
+let i = 10; // Could be a runtime value
+let j = 20;
+&y[i..j];
 

Use instead:

x.get(2);
+x.get(100);
 x.get(2..100);
 
-y.get(10);
-y.get(10..100);
+let i = 10;
+let j = 20;
+y.get(i..j);
 

Configuration