Struct rustc_error_messages::MultiSpan
source · pub struct MultiSpan {
pub(crate) primary_spans: Vec<Span>,
pub(crate) span_labels: Vec<(Span, DiagnosticMessage)>,
}
Expand description
A collection of Span
s.
Spans have two orthogonal attributes:
- They can be primary spans. In this case they are the locus of
the error, and would be rendered with
^^^
. - They can have a label. In this case, the label is written next to the mark in the snippet when we render.
Fields§
§primary_spans: Vec<Span>
§span_labels: Vec<(Span, DiagnosticMessage)>
Implementations§
source§impl MultiSpan
impl MultiSpan
pub fn new() -> MultiSpan
pub fn from_span(primary_span: Span) -> MultiSpan
pub fn from_spans(vec: Vec<Span>) -> MultiSpan
pub fn push_span_label(&mut self, span: Span, label: impl Into<DiagnosticMessage>)
sourcepub fn primary_span(&self) -> Option<Span>
pub fn primary_span(&self) -> Option<Span>
Selects the first primary span (if any).
sourcepub fn primary_spans(&self) -> &[Span]
pub fn primary_spans(&self) -> &[Span]
Returns all primary spans.
sourcepub fn has_primary_spans(&self) -> bool
pub fn has_primary_spans(&self) -> bool
Returns true
if any of the primary spans are displayable.
sourcepub fn is_dummy(&self) -> bool
pub fn is_dummy(&self) -> bool
Returns true
if this contains only a dummy primary span with any hygienic context.
sourcepub fn replace(&mut self, before: Span, after: Span) -> bool
pub fn replace(&mut self, before: Span, after: Span) -> bool
Replaces all occurrences of one Span with another. Used to move Span
s in areas that don’t
display well (like std macros). Returns whether replacements occurred.
sourcepub fn span_labels(&self) -> Vec<SpanLabel>
pub fn span_labels(&self) -> Vec<SpanLabel>
Returns the strings to highlight. We always ensure that there
is an entry for each of the primary spans – for each primary
span P
, if there is at least one label with span P
, we return
those labels (marked as primary). But otherwise we return
SpanLabel
instances with empty labels.
sourcepub fn has_span_labels(&self) -> bool
pub fn has_span_labels(&self) -> bool
Returns true
if any of the span labels is displayable.
Trait Implementations§
impl Eq for MultiSpan
impl StructuralEq for MultiSpan
impl StructuralPartialEq for MultiSpan
Auto Trait Implementations§
impl RefUnwindSafe for MultiSpan
impl !Send for MultiSpan
impl !Sync for MultiSpan
impl Unpin for MultiSpan
impl UnwindSafe for MultiSpan
Blanket Implementations§
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 48 bytes