Struct swc_common::MultiSpan
source · [−]pub struct MultiSpan { /* private fields */ }
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.
Implementations
sourceimpl 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: String)
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 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 Spans in areas that don’t display well (like std macros). Returns true if replacements occurred.
sourcepub fn span_labels(&self) -> Vec<SpanLabel>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn span_labels(&self) -> Vec<SpanLabel>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
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.
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more