HI, I’m a coauthor of that document, and I don’t think that source maps are the right fit here.
The constraints that source maps were designed for aren’t really applicable here.
-
Source maps are separate from the generated code, because actual users of some website don’t care, and don’t want to wait for larger downloads over the network. The generated code links to its source map via a URL, which can be relative, and often accidentally breaks (eg if one of the files is moved and the other isn’t moved with it). The topic at hand doesn’t need to optimize for network traffic, and so shouldn’t take on this headache.
-
Despite that care for reducing network traffic, source maps are utf-8 encoded because at the time working with binary data on the web was a huge pain and not supported everywhere. So in an attempt to keep the utf-8 format compact, the actual debug info is represented with base64 variable length integers. Inheriting this mess would be rather unfortunate.
-
For this topic’s use case, I don’t think we even care that much about being compact, so inline pragmas seem fine.
Additionally, Rust has extant support for a different (and much much much better designed) debugging format: DWARF. DWARF’s .debug_line information maps addresses to {source, line, column, …}. Another possibilty would be to maintain a source to source mapping on the side (Rust to m4, in this case), and do a post-processing pass on the DWARF that rustc emits, fixing the references to generated Rust with reference to the appropraite m4. This experimentation could be done outside of rustc and as a library.
Overall, I think #line "some_file" 42, #[line("some_file", 42)], or line!("some_file", 42) would be the best fit here. Such pragmas are simple to generate and simple to process, and limited in scope.