You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes I don't have access to the source text for one reason or another, but I'd still like to display a message with a file name and line/col numbers, e.g
error: Trait aliases are not supported
--> /rustc/library/core/src/ptr/metadata.rs:81:1
(that's how rustc renders that today).
As far as I can tell this isn't supported with the current API. The closest I managed is to use a snippet with empty source and add the line/col numbers by hand in the origin.
We are working on an API redesign to support Suggestions and it might offer us an opportunity to offer Origin sections that is just file, optional line, optional column without having to have two modes for Snippet where much of the API gets ignored in the second mode.
I'm curious how you have access to line and column information without the source.
It so happens that rustc's SourceFile remembers the mapping from byte to line even when it doesn't remember the whole source text. (I'm not working on rustc mind you, this is for the purposes of a custom rustc driver).
We are working on an API redesign to support Suggestions and it might offer us an opportunity to offer Origin sections that is just file, optional line, optional column without having to have two modes for Snippet where much of the API gets ignored in the second mode.
That sounds good. To be clear the thing that annoys me most in my case is the two extra | lines and the inconsistently indented -->; adding the line number to the origin myself is easy enough. So maybe this doesn't require a whole new mode.
Sometimes I don't have access to the source text for one reason or another, but I'd still like to display a message with a file name and line/col numbers, e.g
(that's how rustc renders that today).
As far as I can tell this isn't supported with the current API. The closest I managed is to use a snippet with empty source and add the line/col numbers by hand in the origin.
I get (note the two empty lines starting with
|
, and the lack of indentation of the-->
arrow):Trying to add an annotation with a span obviously panics because the span is not in range of the empty string.
Would it be possible to have a
Snippet::no_source()
builder that supports annotations with spans and renders them like the above?The text was updated successfully, but these errors were encountered: