diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2016-09-15 18:16:21 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-15 18:16:21 +0530 |
| commit | 69a7f92a7f27632dbe26b91afe95525222cd6349 (patch) | |
| tree | 08b34e5fb7b9146034bb6cf054f08524a450a79a /src/rustllvm/RustWrapper.cpp | |
| parent | bab9238a1ebc26143edb8a0884de5e82463cd459 (diff) | |
| parent | a4ee9c6e96025fa2b5eb254e4ccdd4c6910f5f60 (diff) | |
| download | rust-69a7f92a7f27632dbe26b91afe95525222cd6349.tar.gz rust-69a7f92a7f27632dbe26b91afe95525222cd6349.zip | |
Rollup merge of #36454 - bluss:slice-primitive-index, r=alexcrichton
Use primitive indexing in slice's Index/IndexMut
[T]'s Index implementation is normally not used for indexing, instead
the compiler supplied indexing is used.
Use the compiler supplied version in Index/IndexMut.
This removes an inconsistency:
Compiler supplied bound check failures look like this:
thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 4'
If you convince Rust to use the Index impl for slices, bounds check
failure looks like this instead:
thread 'main' panicked at 'assertion failed: index < self.len()'
The latter is used if you for example use Index generically:
```rust
use std::ops::Index;
fn foo<T: ?Sized>(x: &T) where T: Index<usize> { &x[4]; }
foo(&[1, 2, 3][..])
```
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
