binrw icon indicating copy to clipboard operation
binrw copied to clipboard

Improve error message when arguments aren't passed to a type

Open jam1garner opened this issue 2 years ago • 0 comments

If you miss a count attribute on a Vec right now you get the following:

error[E0277]: the trait bound `VecArgs<()>: Default` is not satisfied
   --> src/segment.rs:34:10
    |
34  | #[derive(BinRead)]
    |          ^^^^^^^ the trait `Default` is not implemented for `VecArgs<()>`
    |
note: required by `std::default::Default::default`
   --> /home/life/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/default.rs:116:5
    |
116 |     fn default() -> Self;
    |     ^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `BinRead` (in Nightly builds, run with -Z macro-backtrace for more info)

this is not good enough to lead users to how to fix their error. Needs improvement.

Needs:

  1. a more specialized message. there's likely some trick to get this error to display the name of a trait or something that gives more information in the form of a NameLikeThisWhichTellsYouWhatsGoingOn
  2. better span information to point to the field in question

jam1garner avatar Sep 30 '21 18:09 jam1garner