An Interactive Debugger for Rust Trait Errors

(cel.cs.brown.edu)

56 points | by matt_d 3 days ago ago

10 comments

  • Rygian 2 days ago ago

    Maybe the example is contrived in a way that does not show the issue very clearly.

    User forgot to include the posts table in the query.

    Error line 1 says "Cannot select `posts::columns::id` from `users::table`.

    For me, that is more than enough to spot the issue. But if I had missed my morning coffee, 5 lines below I have extra help: "note: `posts::columns::id` is no valid selection for `users::table`"

    The rest of the "help" lines I can happily ignore.

  • KingOfCoders 2 days ago ago

    Would have been very useful during my Scala days, I often had lots of type errors with long stacks (heard Scala is different today) that took quite some time to fix.

    Some years ago I came to the conclusion I like Rust compiler errors the most

    https://www.inkmi.com/blog/developer-productivity-compiler-e...

  • Meneth 2 days ago ago

    Feels like Zig's comptime call stacks would make for better error reports than these Rust Traits.

    • Ygg2 2 days ago ago

      Honestly, I think the mismatch is that you have a code that tries too much to do with Traits.

      A simpler, more jooq like interface with strings would work about just as well.

      • adastra22 2 days ago ago

        Type issues no longer a problem when you throw out the type system entirely!

        • Ygg2 2 days ago ago

          Yeah, you're right. We should use build time structures for stuff that can be changed during runtime.

          There is such a thing as going overboard. Remember when Hashtable extended Dictionary in Java, because OOP is teh futureh!

  • quotemstr 2 days ago ago

    LOL. People raked C++ over the coals for having metaprogramming sophisticated enough to need debugging. People mocked projects like Templight (https://llvm.org/devmtg/2015-04/slides/EuroLLVM2015Templight...) as just providing how awful C++ is. Now, when the same thing appears for Rust, it's evidence of how awesome Rust is?

    • spoiler 2 days ago ago

      I used to write C++ for around 10 years. I get the point you're trying to make... Like, both languages sometimes produce errors so long as to seem unhelpful (although the Rust error in this post is actually immediately helpful, so maybe it was a poor example on their part).

      However, comparing Rust traits to template programming seems a bit disingenuous. One is literally a templating engine (albeit powerful one that people got creative with) and the other is part of a fairly cohesive type system (even if it has some downsides).

      Also, I think even the most obtuse errors in Rust are still more helpful than average C++ template error.

  • shaolinspirit 2 days ago ago

    "rust traitors"

    • jgilias 2 days ago ago

      Came to see if someone’s brain parsed it that way too!