-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
index out of bound in slice not caught at compilation #38035
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-mir-opt
Area: MIR optimizations
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
This may need a significant improvement of the compiler, but it's worth doing. |
There are currently lints in clippy for this, I believe. Not sure if the compiler ever plans to add these. |
steveklabnik
added
the
A-diagnostics
Area: Messages for errors, warnings, and lints
label
Nov 29, 2016
steveklabnik
added
the
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
label
Mar 9, 2017
Mark-Simulacrum
added
the
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
label
Jul 26, 2017
estebank
added
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
and removed
A-diagnostics
Area: Messages for errors, warnings, and lints
labels
Dec 13, 2018
oli-obk
added
A-diagnostics
Area: Messages for errors, warnings, and lints
A-mir-opt
Area: MIR optimizations
and removed
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
labels
Oct 9, 2020
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this issue
Oct 5, 2024
…elix Compute array length from type for unconditional panic lint. Fixes rust-lang#98444 The cases that involve slicing are harder, so rust-lang#38035 remains open.
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Oct 5, 2024
Rollup merge of rust-lang#129517 - cjgillot:known-panic-array, r=pnkfelix Compute array length from type for unconditional panic lint. Fixes rust-lang#98444 The cases that involve slicing are harder, so rust-lang#38035 remains open.
flip1995
pushed a commit
to flip1995/rust-clippy
that referenced
this issue
Oct 10, 2024
Compute array length from type for unconditional panic lint. Fixes rust-lang/rust#98444 The cases that involve slicing are harder, so rust-lang/rust#38035 remains open.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-mir-opt
Area: MIR optimizations
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Hi! I'm just learning Rust! I saw this odd behavior, where the compiler will nicely tell me that an index in an array is impossible at compile time, but won't tell me that an index in a slice of known size is also impossible.
I thought I'd share.
This fails at compile time:
This fails at runtime:
Would be cool if
&y[0..1][1]
also failed at compile time.The text was updated successfully, but these errors were encountered: