Error spans with Custom Derive Output


I just spent about 20 minutes debugging an error in the output of some #[derive(Foo)] code of mine with a very unhelpful error span. Turns out the error was that I’d imported an overloaded Result type elsewhere with a different number of arguments to the std one the derive code was using. That’s not the issue I’m interested in though, I obviously need to be more explicit about the types I’m dealing with in the derive code.

The issue is that there was no way I could figure it out until I slapped the derive output into the file and saw the span over Result when building.

Is it possible to display custom derive macro output with decent error spans by default when that code causes a compiler error?

CC: @dtolnay