Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upConfusing Error Message On Not Specifying Trait Bound In Generic Function Signature #41030
Comments
sfackler
added
the
A-diagnostics
label
Apr 3, 2017
This comment has been minimized.
This comment has been minimized.
|
Today, we suggest that the method exists, but we somehow fail to see that it exists on Minimum in the first note and then latter note it in the second note.
|
This comment has been minimized.
This comment has been minimized.
|
It still doesn't help a lot IMO... since the problem is the bound isn't declared in the signature, and nothing regarding declaration is mentioned.
maybe change to
|
Mark-Simulacrum
added
the
C-enhancement
label
Jul 26, 2017
This comment has been minimized.
This comment has been minimized.
|
I think that can be easily fixed by checking if Do you have suggestion how the error should look like? Does that sound ok?
|
This comment has been minimized.
This comment has been minimized.
|
@pornel From my perspective, I think the problem is one of asymmetry in the help section. It mentioned "items from traits can only be used if the trait is implemented and in scope", but then went on to only suggest "perhaps you need to implement one of them". Excuse me for being insistent on this, but I believe the best way is to remind that to bring function into scope the trait bound needs to be declared as well as implemented. |
This comment has been minimized.
This comment has been minimized.
|
LOL this is actually a duplicate of #21673 . There's even a FIXME note in the source. |
This comment has been minimized.
This comment has been minimized.
|
@louy2 I think we're talking about different cases (which may be another reason to split or reword the message). For methods the message says "method not found", but adds a note saying "the method exists", which I really don't like, because it's very easy to miss the nuance and interpret the message as nonsense "the method does not exist" "but it exists". I've explained more here: https://internals.rust-lang.org/t/multiple-variants-of-the-same-erorr-message/6002 |
louy2 commentedApr 3, 2017
•
edited by estebank
I am working through this Rust-101 tutorial and is faced with such a challenge:
So I tried it. Rust complained, but in a pretty confusing way:
The minimal code that produces the error message is
The error message tells me that I need to implement a trait. Since I have already implemented it, I would be confused by the error message, and misled by it from the actual reason, failure to declare it in the signature. I think it would be better if the message is changed to
On the other hand, if I actually drop the block
impl Minimum for i32, but declareMinimumin the signature, the error message iswhich is straightforward enough.