Closed
Description
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.
let origin = format!("{}:{}:{}", file.name, span.beg.line, span.beg.col + 1);
let snippet = Snippet::source("").origin(&origin);
let message = level.title(&msg).snippet(snippet);
I get (note the two empty lines starting with |
, and the lack of indentation of the -->
arrow):
error: Trait aliases are not supported
--> /rustc/library/core/src/ptr/metadata.rs:81:1
|
|
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?
Metadata
Metadata
Assignees
Labels
No labels