-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Description
Currently, if I try to index a [T]
by a u8
(buf[1u8]
, or whatever), I'll get the error
test.rs:6:15: 6:19 error: the trait `core::ops::Index<u8>` is not implemented for the type `[u8]` [E0277]
test.rs:6 println!("{}",y[x])
It would be helpful in such a situation for a note saying that there is an implementation of Index<usize>
.
Basically: If a trait isn't found to be implemented, but a version of that trait with different type parameters is, show some help
messages containing the candidates. We do something like this already when one tries to call a nonexistent method on a type where bringing some trait into scope might make it work.
In this case, it should show something along the lines of:
test.rs:7:22: 7:22 help: the following implementations were found:
test.rs:7:22: 7:22 help: implementation #1: `Index<usize>`
``
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.