pub struct SpanLabel {
pub span: Span<BytePos>,
pub message: String,
pub primary: bool,
pub file: Option<SourceFileId>,
}Expand description
One underlined region of the user’s source, and what to say about it.
§file: when a label is not about the module under check
A [codespan_reporting::diagnostic::Label] needs a file id as well as a byte range. Most
labels don’t carry one themselves: a phase only ever sees one module, so its
spans belong to the file that module was read from, and check_package —
the only place that knows which file that is — supplies it for the whole
diagnostic at render time. file: None is that case, and it covers everything
built before ERR-5.
Some is the escape hatch: a label built from a SourceSpan cloned out of an
Interface (via Interface::source_span) already carries its own file,
generally a different one from the module being checked — “the annotation you
are contradicting is over there, in Basics” — and that id is used verbatim
instead of the diagnostic’s.
primary is the rustc distinction, and it applies independently of file: the
caret under the thing that is wrong is primary even when it is local, and
“defined here” in another file is secondary even though it is the only label
pointing into that file.
Fields§
§span: Span<BytePos>§message: String§primary: bool§file: Option<SourceFileId>