Trait rustc_utils::source_map::span::SpanExt
source · pub trait SpanExt {
// Required methods
fn subtract(&self, child_spans: Vec<Span>) -> Vec<Span>;
fn as_local(&self, outer_span: Span) -> Option<Span>;
fn overlaps_inclusive(&self, other: Span) -> bool;
fn trim_end(&self, other: Span) -> Option<Span>;
fn merge_overlaps(spans: Vec<Span>) -> Vec<Span>;
fn trim_leading_whitespace(
&self,
source_map: &SourceMap
) -> Option<Vec<Span>>;
fn to_string(&self, tcx: TyCtxt<'_>) -> String;
fn size(&self) -> u32;
}Expand description
Extension trait for Span.
Required Methods§
sourcefn subtract(&self, child_spans: Vec<Span>) -> Vec<Span>
fn subtract(&self, child_spans: Vec<Span>) -> Vec<Span>
Returns spans for regions in self not in child_spans.
For example:
self: ---------------
child_spans: --- -- ---
output: - ------ --
sourcefn as_local(&self, outer_span: Span) -> Option<Span>
fn as_local(&self, outer_span: Span) -> Option<Span>
Returns the version of this span that is local to the current
crate, and must be contained in outer_span.
sourcefn overlaps_inclusive(&self, other: Span) -> bool
fn overlaps_inclusive(&self, other: Span) -> bool
Returns true if self overlaps with other including boundaries.
sourcefn trim_end(&self, other: Span) -> Option<Span>
fn trim_end(&self, other: Span) -> Option<Span>
Returns a new span whose end is no later than the start of other,
returning None if this would return an empty span.
sourcefn merge_overlaps(spans: Vec<Span>) -> Vec<Span>
fn merge_overlaps(spans: Vec<Span>) -> Vec<Span>
Merges all overlapping spans in the input vector into single spans.
sourcefn trim_leading_whitespace(&self, source_map: &SourceMap) -> Option<Vec<Span>>
fn trim_leading_whitespace(&self, source_map: &SourceMap) -> Option<Vec<Span>>
Returns a collection of spans inside self that have leading whitespace removed.
Returns None if SourceMap::span_to_snippet fails.
Object Safety§
This trait is not object safe.