mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
6efddac288
Expand the primary span of E0277 when the immediate unmet bound is not what the user wrote: ``` error[E0277]: the trait bound `i32: Bar` is not satisfied --> f100.rs:6:6 | 6 | <i32 as Foo>::foo(); | ^^^ the trait `Bar` is not implemented for `i32`, which is required by `i32: Foo` | help: this trait has no implementations, consider adding one --> f100.rs:2:1 | 2 | trait Bar {} | ^^^^^^^^^ note: required for `i32` to implement `Foo` --> f100.rs:3:14 | 3 | impl<T: Bar> Foo for T {} | --- ^^^ ^ | | | unsatisfied trait bound introduced here ``` Fix #40120.
58 lines
2.7 KiB
Plaintext
58 lines
2.7 KiB
Plaintext
error[E0277]: the type `str` cannot be indexed by `{integer}`
|
|
--> $DIR/str-idx.rs:3:19
|
|
|
|
|
LL | let _: u8 = s[4];
|
|
| ^ string indices are ranges of `usize`
|
|
|
|
|
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`, which is required by `str: Index<_>`
|
|
= note: you can use `.chars().nth()` or `.bytes().nth()`
|
|
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
|
|
= help: the trait `SliceIndex<[_]>` is implemented for `usize`
|
|
= help: for that trait implementation, expected `[_]`, found `str`
|
|
= note: required for `str` to implement `Index<{integer}>`
|
|
|
|
error[E0277]: the type `str` cannot be indexed by `{integer}`
|
|
--> $DIR/str-idx.rs:4:19
|
|
|
|
|
LL | let _ = s.get(4);
|
|
| --- ^ string indices are ranges of `usize`
|
|
| |
|
|
| required by a bound introduced by this call
|
|
|
|
|
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
|
|
= note: you can use `.chars().nth()` or `.bytes().nth()`
|
|
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
|
|
= help: the trait `SliceIndex<[_]>` is implemented for `usize`
|
|
= help: for that trait implementation, expected `[_]`, found `str`
|
|
note: required by a bound in `core::str::<impl str>::get`
|
|
--> $SRC_DIR/core/src/str/mod.rs:LL:COL
|
|
|
|
error[E0277]: the type `str` cannot be indexed by `{integer}`
|
|
--> $DIR/str-idx.rs:5:29
|
|
|
|
|
LL | let _ = s.get_unchecked(4);
|
|
| ------------- ^ string indices are ranges of `usize`
|
|
| |
|
|
| required by a bound introduced by this call
|
|
|
|
|
= help: the trait `SliceIndex<str>` is not implemented for `{integer}`
|
|
= note: you can use `.chars().nth()` or `.bytes().nth()`
|
|
for more information, see chapter 8 in The Book: <https://doc.rust-lang.org/book/ch08-02-strings.html#indexing-into-strings>
|
|
= help: the trait `SliceIndex<[_]>` is implemented for `usize`
|
|
= help: for that trait implementation, expected `[_]`, found `str`
|
|
note: required by a bound in `core::str::<impl str>::get_unchecked`
|
|
--> $SRC_DIR/core/src/str/mod.rs:LL:COL
|
|
|
|
error[E0277]: the type `str` cannot be indexed by `char`
|
|
--> $DIR/str-idx.rs:6:19
|
|
|
|
|
LL | let _: u8 = s['c'];
|
|
| ^^^ string indices are ranges of `usize`
|
|
|
|
|
= help: the trait `SliceIndex<str>` is not implemented for `char`, which is required by `str: Index<_>`
|
|
= note: required for `str` to implement `Index<char>`
|
|
|
|
error: aborting due to 4 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0277`.
|