Present useful error messages when the user's code has errors
The code that the user puts inside the gobject_gen!{}
invocation can have errors:
- Parse errors - these get caught by the
syn
machinery. - Semantic errors - we check for these when building the HIR.
Currently we do a very poor job of reporting those errors to the user. We panic, or bail!
, and neither of these makes rustc present a nice error message to the user about their code.
This is a tracking issue, since we need to fix several things first:
-
Make syn
return useful errors from::parse()
; right now they contain no information. We need a description and a span, or aproc_macro::Diagnostic
that is ready to be emitted, or something. (Upstream tracker for proc-macro in general; Upstream bug about error reporting in syn). -
Replace our use of bail!
and panics during parsing with a useful mechanism (depends onsyn
). -
Present semantic errors nicely. See what relm does. -
Use the compiletest_rs crate to test our error messages
Edited by Federico Mena Quintero