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

Document that index and index_mut can panic #84301

Merged
merged 2 commits into from Apr 22, 2021
Merged

Conversation

wooster0
Copy link
Contributor

I thought this was noteworthy and I think a bit more explicitness does no harm.

@rust-highfive
Copy link
Collaborator

r? @kennytm

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 18, 2021
@jonas-schievink
Copy link
Contributor

Since this is a property of the implementation, not the trait, should it maybe go on the implementations in libcore/liballoc? Or maybe the docs on the trait should specify that implementations may panic instead, not that they will?

@wooster0
Copy link
Contributor Author

wooster0 commented Apr 18, 2021

Since this is a property of the implementation, not the trait, should it maybe go on the implementations in libcore/liballoc?

Do you mean it should go to https://doc.rust-lang.org/alloc/vec/struct.Vec.html#method.index, https://doc.rust-lang.org/alloc/string/struct.String.html#method.index and so on? It seems the documentation of those is automatically copied from IndexMut::index_mut and Index::index so that is probably not possible.

Or maybe the docs on the trait should specify that implementations may panic instead, not that they will?

Good point, it's not enforced that they need to panic if the index is out of bounds so I will change that.

@kennytm
Copy link
Member

kennytm commented Apr 20, 2021

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 20, 2021

📌 Commit c86ffe9 has been approved by kennytm

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 20, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 20, 2021
Document that `index` and `index_mut` can panic

I thought this was noteworthy and I think a bit more explicitness does no harm.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 21, 2021
Document that `index` and `index_mut` can panic

I thought this was noteworthy and I think a bit more explicitness does no harm.
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Apr 21, 2021
Document that `index` and `index_mut` can panic

I thought this was noteworthy and I think a bit more explicitness does no harm.
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 22, 2021
Rollup of 12 pull requests

Successful merges:

 - rust-lang#84013 (Replace all `fmt.pad` with `debug_struct`)
 - rust-lang#84119 (Move `sys::vxworks` code to `sys::unix`)
 - rust-lang#84212 (Replace `Void` in `sys` with never type)
 - rust-lang#84251 (fix 'const-stable since' for NonZeroU*::new_unchecked)
 - rust-lang#84301 (Document that `index` and `index_mut` can panic)
 - rust-lang#84365 (Improve the docstrings of the `Lto` struct.)
 - rust-lang#84378 (Fix broken doc link)
 - rust-lang#84379 (Add GAT related tests)
 - rust-lang#84380 (Write Rustdoc titles like "x in crate::mod - Rust")
 - rust-lang#84390 (Format `Struct { .. }` on one line even with `{:#?}`.)
 - rust-lang#84393 (Support `x.py doc std --open`)
 - rust-lang#84406 (Remove `delete` alias from `mem::drop`.)

Failed merges:

 - rust-lang#84387 (Move `sys_common::poison` to `sync::poison`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d341851 into rust-lang:master Apr 22, 2021
@rustbot rustbot added this to the 1.53.0 milestone Apr 22, 2021
@wooster0 wooster0 deleted the patch-1 branch September 24, 2021 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants