about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-09-15 18:16:21 +0530
committerGitHub <noreply@github.com>2016-09-15 18:16:21 +0530
commit69a7f92a7f27632dbe26b91afe95525222cd6349 (patch)
tree08b34e5fb7b9146034bb6cf054f08524a450a79a /src/rustllvm/RustWrapper.cpp
parentbab9238a1ebc26143edb8a0884de5e82463cd459 (diff)
parenta4ee9c6e96025fa2b5eb254e4ccdd4c6910f5f60 (diff)
downloadrust-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