File tree Expand file tree Collapse file tree 2 files changed +21
-24
lines changed Expand file tree Collapse file tree 2 files changed +21
-24
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- }
2
+ "tags" : [
3
+ " clippy" ,
4
+ " out_of_bounds_indexing"
5
+ ]
6
+ }
Original file line number Diff line number Diff line change 1
- FIXME: add a description
2
-
3
- // If you want to factorize the description uncomment the following line and create the file.
4
- //include::../description.adoc[]
5
-
6
1
== Why is this an issue?
7
2
8
- FIXME: remove the unused optional headers (that are commented out)
3
+ An array index out-of-bounds panic is a bug class that occurs in Rust when a
4
+ program tries to access an array element that does not exist.
5
+ This bug can cause your program to crash or behave unexpectedly.
9
6
10
- //=== What is the potential impact?
7
+ include::../ impact.adoc[]
11
8
12
9
== How to fix it
13
- //== How to fix it in FRAMEWORK NAME
10
+
11
+ To fix an array index out of bounds panic in Rust, you should always ensure
12
+ that you are accessing array elements within the bounds of the array.
14
13
15
14
=== Code examples
16
15
17
16
==== Noncompliant code example
18
17
19
18
[source,rust,diff-id=1,diff-type=noncompliant]
20
19
----
21
- FIXME
20
+ let x = [1, 2, 3, 4];
21
+
22
+ x[9]; // Out of bounds indexing
22
23
----
23
24
24
25
==== Compliant solution
25
26
26
27
[source,rust,diff-id=1,diff-type=compliant]
27
28
----
28
- FIXME
29
- ----
30
-
31
- //=== How does this work?
29
+ let x = [1, 2, 3, 4];
32
30
33
- //=== Pitfalls
34
-
35
- //=== Going the extra mile
31
+ x[0];
32
+ ----
36
33
34
+ == Resources
35
+ === Documentation
37
36
38
- //== Resources
39
- //=== Documentation
40
- //=== Articles & blog posts
41
- //=== Conference presentations
42
- //=== Standards
43
- //=== External coding guidelines
44
- //=== Benchmarks
37
+ * Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#out_of_bounds_indexing
You can’t perform that action at this time.
0 commit comments