Skip to content

Commit 65680c0

Browse files
Update RSPEC
1 parent ea9ecf0 commit 65680c0

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

rules/S6466/rust/metadata.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
{
2-
}
2+
"tags": [
3+
"clippy",
4+
"out_of_bounds_indexing"
5+
]
6+
}

rules/S6466/rust/rule.adoc

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,37 @@
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-
61
== Why is this an issue?
72

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.
96

10-
//=== What is the potential impact?
7+
include::../impact.adoc[]
118

129
== 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.
1413

1514
=== Code examples
1615

1716
==== Noncompliant code example
1817

1918
[source,rust,diff-id=1,diff-type=noncompliant]
2019
----
21-
FIXME
20+
let x = [1, 2, 3, 4];
21+
22+
x[9]; // Out of bounds indexing
2223
----
2324

2425
==== Compliant solution
2526

2627
[source,rust,diff-id=1,diff-type=compliant]
2728
----
28-
FIXME
29-
----
30-
31-
//=== How does this work?
29+
let x = [1, 2, 3, 4];
3230
33-
//=== Pitfalls
34-
35-
//=== Going the extra mile
31+
x[0];
32+
----
3633

34+
== Resources
35+
=== Documentation
3736

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

0 commit comments

Comments
 (0)