]> git.lizzy.rs Git - rust.git/blob - tests/ui/str/str-idx.stderr
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / tests / ui / str / str-idx.stderr
1 error[E0277]: the type `str` cannot be indexed by `{integer}`
2   --> $DIR/str-idx.rs:3:19
3    |
4 LL |     let _: u8 = s[4];
5    |                   ^ string indices are ranges of `usize`
6    |
7    = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
8    = note: you can use `.chars().nth()` or `.bytes().nth()`
9            for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
10    = help: the trait `SliceIndex<[T]>` is implemented for `usize`
11    = note: required for `str` to implement `Index<{integer}>`
12
13 error[E0277]: the type `str` cannot be indexed by `{integer}`
14   --> $DIR/str-idx.rs:4:19
15    |
16 LL |     let _ = s.get(4);
17    |               --- ^ string indices are ranges of `usize`
18    |               |
19    |               required by a bound introduced by this call
20    |
21    = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
22    = note: you can use `.chars().nth()` or `.bytes().nth()`
23            for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
24    = help: the trait `SliceIndex<[T]>` is implemented for `usize`
25 note: required by a bound in `core::str::<impl str>::get`
26   --> $SRC_DIR/core/src/str/mod.rs:LL:COL
27
28 error[E0277]: the type `str` cannot be indexed by `{integer}`
29   --> $DIR/str-idx.rs:5:29
30    |
31 LL |     let _ = s.get_unchecked(4);
32    |               ------------- ^ string indices are ranges of `usize`
33    |               |
34    |               required by a bound introduced by this call
35    |
36    = help: the trait `SliceIndex<str>` is not implemented for `{integer}`
37    = note: you can use `.chars().nth()` or `.bytes().nth()`
38            for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
39    = help: the trait `SliceIndex<[T]>` is implemented for `usize`
40 note: required by a bound in `core::str::<impl str>::get_unchecked`
41   --> $SRC_DIR/core/src/str/mod.rs:LL:COL
42
43 error[E0277]: the type `str` cannot be indexed by `char`
44   --> $DIR/str-idx.rs:6:19
45    |
46 LL |     let _: u8 = s['c'];
47    |                   ^^^ string indices are ranges of `usize`
48    |
49    = help: the trait `SliceIndex<str>` is not implemented for `char`
50    = note: required for `str` to implement `Index<char>`
51
52 error: aborting due to 4 previous errors
53
54 For more information about this error, try `rustc --explain E0277`.