(May be) misleading error message?

@arielb1 What about?

error: the trait `core::fmt::Debug` is not necessarily implemented for the generic type `T`

help: consider adding a constraint on type `T` with `where T: core::fmt::Debug::fmt` 
help: ...or implement `core::fmt::Debug::fmt` for type `T`

Emphasis on not necessarily and the generic type T.

I would find this kind of error message helpful.

1 Like

+1 I like this a lot

I don't like the long-form error message. It occurs a lot, and the current one is too long already.

Plus, I prefer a single primary error for all E0277 errors, whether generic or not (and to vary only the helps)

Fair enough, in that case you could set a shorter error message that fits all cases and display the error and help message I proposed only as help message when a generic type does not implement a trait?

I think that would be equally helpful, what do you think?

My current suggestion is:

note.rs:2:22: 2:23 error: the predicate `T : core::fmt::Debug` is not satisfied [E0277]
note.rs:2     println!("{:?}", t);
<std macros>:2:25: 2:56 note: in this expansion of format_args!
<std macros>:3:1: 3:54 note: in this expansion of print! (defined in <std macros>)
note.rs:2:5: 2:25 note: in this expansion of println! (defined in <std macros>)
note.rs:2:22: 2:23 help: run `rustc --explain E0277` to see a detailed explanation
note.rs:2:22: 2:23 help: consider adding a `where T : core::fmt::Debug` bound
note.rs:2:22: 2:23 note: required by `core::fmt::Debug::fmt`

The issue whit this message is that it's pretty technical. I am not a native English speaker, but I do think my English is relatively good. And yet I had never heard of the term predicate. As docs and error messages are exclusively written in English I think they should at least use "simple" terms for all of us, non-native speakers :slight_smile:

I think this is great and I like this a lot better than before. What do you think about putting a concrete hint into the help message like this?:

help: consider changing the impl declaration to 'impl<T : fmt::Debug> Info for Buffer<T>'

This would help decoding all the cryptic terms for the beginners. (The advanced users haven't had a problem with the message anyways.)

predicate is a technical term. Maybe use "the trait bound"?

Yes, that is way better in my opinion

I agree, the goal here is to make errors user-friendly, which means not introducing new jargon when they're already staring helplessly at an error message. We already use "trait bound" rather than "predicate" in the book and elsewhere, so sticking with the former is more consistent and will have better googlability..