Skip to content
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

Chapter 3.2 Attempting to access an out of bounds array element is caught at compile time - not at runtime #2438

Closed
j-medland opened this issue Aug 25, 2020 · 1 comment

Comments

@j-medland
Copy link

With Rust 1.45.2 (d3fb005a3 2020-07-31) attempting to access an array element which is unconditionally out of bounds is caught and reported with a compilation error as oppose to causing a runtime panic as the example suggests.

I get the following output:

Compiling arrays v0.1.0 (file:///projects/arrays)
error: this operation will panic at runtime
 --> src/main.rs:5:19
  |
5 |     let element = a[index];
  |                   ^^^^^^^^ index out of bounds: the len is 5 but the index is 10
  |
  = note: `#[deny(unconditional_panic)]` on by default

error: aborting due to previous error
@steveklabnik
Copy link
Member

This is a duplicate of #2417 though, so I'm going to close it in favor of that one.

Thank you for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants