`Span` for external data files.
When writing proc macro, sometimes it's convenient to parse external data file and generate code accordingly. It would be nice to allow creating Spans corresponding to byte ranges within the data file, and use them in compiler diagnostics information.
One specific example where the external data is a piece of Rust code, is at https://github.com/dtolnay/request-for-implementation/issues/47 .
I think it would be enabler for compile-to-Rust languages, e.g. support for experimental syntax or custom syntax sugar.
I would also like this for crates like ructe that compile HTML-like templates to Rust code. Currently it's done in build.rs and errors in templates point to temporary files in OUT_DIR. It's not a great experience. If the template compiler could be converted to a proc_macro with support for spans, it'd work beautifully with errors spans showing in HTML!
It is absolutely necessary for yarte, which combines its own parser with syn and mixes the errors. Currently I was taking advantage of a proc_macro2 bug in LineColumn that returned bytes. They have solved it and there is no way.
If it can be given more importance, in yarte it is essential for correct error management.
The API for getting the file of a Span was recently stabilised. Unfortunately it doesn't look like there's even an unstable API to set it. It seems like a Span has references back to internal rustc file maps, so it might not be totally trivial. Still I think you could do it and this would be super useful.