Description
I've been seeing more and more questions along the lines of this StackOverflow question. A user tries to call a method that is in the docs, but the compiler insists it doesn't exist. It turns out that this is because the method is only implemented provided certain generic constraints are satisfied, but they aren't.
The compiler does not mention this.
The only way a new user would find out about this is if they scroll up from the documentation on the method, and realise that the impl...
header applies to everything below it, which isn't immediately obvious.
I think that the compiler should make a bit more of an effort here: if there is a method with the given name, but it doesn't satisfy one or more constraints, the compiler should at least add a note along the lines of:
Method exists, but one or more constraints are not satisfied.
Preferably, it would change the whole error from:
type `core::result::Result<u32, Error>` does not implement any method in scope named `unwrap`
To something like:
error: method `unwrap` is unavailable due to unsatisfied constraints for type `core::result::Result<u32, Error>`
note: `unwrap` requires: `Error: Debug`.
(Language mangled a bit to put the potentially long type name at the end.)