pub struct MultiSpan {
    pub(crate) primary_spans: Vec<Span>,
    pub(crate) span_labels: Vec<(Span, DiagnosticMessage)>,
}
Expand description

A collection of Spans.

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

source

pub fn new() -> MultiSpan

source

pub fn from_span(primary_span: Span) -> MultiSpan

source

pub fn from_spans(vec: Vec<Span>) -> MultiSpan

source

pub fn push_span_label( &mut self, span: Span, label: impl Into<DiagnosticMessage> )

source

pub fn primary_span(&self) -> Option<Span>

Selects the first primary span (if any).

source

pub fn primary_spans(&self) -> &[Span]

Returns all primary spans.

source

pub fn has_primary_spans(&self) -> bool

Returns true if any of the primary spans are displayable.

source

pub fn is_dummy(&self) -> bool

Returns true if this contains only a dummy primary span with any hygienic context.

source

pub fn replace(&mut self, before: Span, after: Span) -> bool

Replaces all occurrences of one Span with another. Used to move Spans in areas that don’t display well (like std macros). Returns whether replacements occurred.

source

pub fn pop_span_label(&mut self) -> Option<(Span, DiagnosticMessage)>

source

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.

source

pub fn has_span_labels(&self) -> bool

Returns true if any of the span labels is displayable.

source

pub fn clone_ignoring_labels(&self) -> Self

Clone this MultiSpan without keeping any of the span labels - sometimes a MultiSpan is to be re-used in another diagnostic, but includes span_labels which have translated messages. These translated messages would fail to translate without their diagnostic arguments which are unlikely to be cloned alongside the Span.

Trait Implementations§

source§

impl Clone for MultiSpan

source§

fn clone(&self) -> MultiSpan

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MultiSpan

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<__D: SpanDecoder> Decodable<__D> for MultiSpan

source§

fn decode(__decoder: &mut __D) -> Self

source§

impl<__E: SpanEncoder> Encodable<__E> for MultiSpan

source§

fn encode(&self, __encoder: &mut __E)

source§

impl From<Span> for MultiSpan

source§

fn from(span: Span) -> MultiSpan

Converts to this type from the input type.
source§

impl From<Vec<Span>> for MultiSpan

source§

fn from(spans: Vec<Span>) -> MultiSpan

Converts to this type from the input type.
source§

impl Hash for MultiSpan

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for MultiSpan

source§

fn eq(&self, other: &MultiSpan) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for MultiSpan

source§

impl StructuralPartialEq for MultiSpan

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

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