Struct rustc_ap_rustc_span::source_map::SourceMap [−][src]
pub struct SourceMap { /* fields omitted */ }
Implementations
impl SourceMap
[src]
impl SourceMap
[src]pub fn new(path_mapping: FilePathMapping) -> SourceMap
[src]
pub fn with_file_loader_and_hash_kind(
file_loader: Box<dyn FileLoader + Sync + Send>,
path_mapping: FilePathMapping,
hash_kind: SourceFileHashAlgorithm
) -> SourceMap
[src]
file_loader: Box<dyn FileLoader + Sync + Send>,
path_mapping: FilePathMapping,
hash_kind: SourceFileHashAlgorithm
) -> SourceMap
pub fn path_mapping(&self) -> &FilePathMapping
[src]
pub fn file_exists(&self, path: &Path) -> bool
[src]
pub fn load_file(&self, path: &Path) -> Result<Lrc<SourceFile>>
[src]
pub fn load_binary_file(&self, path: &Path) -> Result<Vec<u8>>
[src]
pub fn load_binary_file(&self, path: &Path) -> Result<Vec<u8>>
[src]Loads source file as a binary blob.
Unlike load_file
, guarantees that no normalization like BOM-removal
takes place.
pub fn files(&self) -> MappedReadGuard<'_, MonotonicVec<Lrc<SourceFile>>>
[src]
pub fn source_file_by_stable_id(
&self,
stable_id: StableSourceFileId
) -> Option<Lrc<SourceFile>>
[src]
&self,
stable_id: StableSourceFileId
) -> Option<Lrc<SourceFile>>
pub fn new_source_file(
&self,
filename: FileName,
src: String
) -> Lrc<SourceFile>
[src]
pub fn new_source_file(
&self,
filename: FileName,
src: String
) -> Lrc<SourceFile>
[src]Creates a new SourceFile
.
If a file already exists in the SourceMap
with the same ID, that file is returned
unmodified.
pub fn new_imported_source_file(
&self,
filename: FileName,
src_hash: SourceFileHash,
name_hash: u128,
source_len: usize,
cnum: CrateNum,
file_local_lines: Vec<BytePos>,
file_local_multibyte_chars: Vec<MultiByteChar>,
file_local_non_narrow_chars: Vec<NonNarrowChar>,
file_local_normalized_pos: Vec<NormalizedPos>,
original_start_pos: BytePos,
original_end_pos: BytePos
) -> Lrc<SourceFile>
[src]
pub fn new_imported_source_file(
&self,
filename: FileName,
src_hash: SourceFileHash,
name_hash: u128,
source_len: usize,
cnum: CrateNum,
file_local_lines: Vec<BytePos>,
file_local_multibyte_chars: Vec<MultiByteChar>,
file_local_non_narrow_chars: Vec<NonNarrowChar>,
file_local_normalized_pos: Vec<NormalizedPos>,
original_start_pos: BytePos,
original_end_pos: BytePos
) -> Lrc<SourceFile>
[src]Allocates a new SourceFile
representing a source file from an external
crate. The source code of such an “imported SourceFile
” is not available,
but we still know enough to generate accurate debuginfo location
information for things inlined from other crates.
pub fn doctest_offset_line(&self, file: &FileName, orig: usize) -> usize
[src]
pub fn lookup_source_file(&self, pos: BytePos) -> Lrc<SourceFile>
[src]
pub fn lookup_source_file(&self, pos: BytePos) -> Lrc<SourceFile>
[src]Return the SourceFile that contains the given BytePos
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc
[src]
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc
[src]Looks up source information about a BytePos
.
pub fn lookup_line(
&self,
pos: BytePos
) -> Result<SourceFileAndLine, Lrc<SourceFile>>
[src]
&self,
pos: BytePos
) -> Result<SourceFileAndLine, Lrc<SourceFile>>
pub fn span_to_embeddable_string(&self, sp: Span) -> String
[src]
pub fn span_to_embeddable_string(&self, sp: Span) -> String
[src]Format the span location suitable for embedding in build artifacts
pub fn span_to_diagnostic_string(&self, sp: Span) -> String
[src]
pub fn span_to_diagnostic_string(&self, sp: Span) -> String
[src]Format the span location to be printed in diagnostics. Must not be emitted to build artifacts as this may leak local file paths. Use span_to_embeddable_string for string suitable for embedding.
pub fn span_to_filename(&self, sp: Span) -> FileName
[src]
pub fn is_multiline(&self, sp: Span) -> bool
[src]
pub fn is_valid_span(&self, sp: Span) -> Result<(Loc, Loc), SpanLinesError>
[src]
pub fn is_line_before_span_empty(&self, sp: Span) -> bool
[src]
pub fn span_to_lines(&self, sp: Span) -> FileLinesResult
[src]
pub fn span_to_snippet(&self, sp: Span) -> Result<String, SpanSnippetError>
[src]
pub fn span_to_snippet(&self, sp: Span) -> Result<String, SpanSnippetError>
[src]Returns the source snippet as String
corresponding to the given Span
.
pub fn span_to_margin(&self, sp: Span) -> Option<usize>
[src]
pub fn span_to_prev_source(&self, sp: Span) -> Result<String, SpanSnippetError>
[src]
pub fn span_to_prev_source(&self, sp: Span) -> Result<String, SpanSnippetError>
[src]Returns the source snippet as String
before the given Span
.
pub fn span_extend_to_prev_char(
&self,
sp: Span,
c: char,
accept_newlines: bool
) -> Span
[src]
pub fn span_extend_to_prev_char(
&self,
sp: Span,
c: char,
accept_newlines: bool
) -> Span
[src]Extends the given Span
to just after the previous occurrence of c
. Return the same span
if no character could be found or if an error occurred while retrieving the code snippet.
pub fn span_extend_to_prev_str(
&self,
sp: Span,
pat: &str,
accept_newlines: bool
) -> Span
[src]
pub fn span_extend_to_prev_str(
&self,
sp: Span,
pat: &str,
accept_newlines: bool
) -> Span
[src]Extends the given Span
to just after the previous occurrence of pat
when surrounded by
whitespace. Returns the same span if no character could be found or if an error occurred
while retrieving the code snippet.
pub fn span_to_next_source(&self, sp: Span) -> Result<String, SpanSnippetError>
[src]
pub fn span_to_next_source(&self, sp: Span) -> Result<String, SpanSnippetError>
[src]Returns the source snippet as String
after the given Span
.
pub fn span_extend_to_next_char(
&self,
sp: Span,
c: char,
accept_newlines: bool
) -> Span
[src]
pub fn span_extend_to_next_char(
&self,
sp: Span,
c: char,
accept_newlines: bool
) -> Span
[src]Extends the given Span
to just after the next occurrence of c
.
pub fn span_until_char(&self, sp: Span, c: char) -> Span
[src]
pub fn span_until_char(&self, sp: Span, c: char) -> Span
[src]Given a Span
, tries to get a shorter span ending before the first occurrence of char
c
.
pub fn span_through_char(&self, sp: Span, c: char) -> Span
[src]
pub fn span_through_char(&self, sp: Span, c: char) -> Span
[src]Given a Span
, tries to get a shorter span ending just after the first occurrence of char
c
.
pub fn span_until_non_whitespace(&self, sp: Span) -> Span
[src]
pub fn span_until_non_whitespace(&self, sp: Span) -> Span
[src]Given a Span
, gets a new Span
covering the first token and all its trailing whitespace
or the original Span
.
If sp
points to "let mut x"
, then a span pointing at "let "
will be returned.
pub fn span_until_whitespace(&self, sp: Span) -> Span
[src]
pub fn span_until_whitespace(&self, sp: Span) -> Span
[src]Given a Span
, gets a new Span
covering the first token without its trailing whitespace
or the original Span
in case of error.
If sp
points to "let mut x"
, then a span pointing at "let"
will be returned.
pub fn span_take_while<P>(&self, sp: Span, predicate: P) -> Span where
P: for<'r> FnMut(&'r char) -> bool,
[src]
pub fn span_take_while<P>(&self, sp: Span, predicate: P) -> Span where
P: for<'r> FnMut(&'r char) -> bool,
[src]Given a Span
, gets a shorter one until predicate
yields false
.
pub fn guess_head_span(&self, sp: Span) -> Span
[src]
pub fn guess_head_span(&self, sp: Span) -> Span
[src]Given a Span
, return a span ending in the closest {
. This is useful when you have a
Span
enclosing a whole item but we need to point at only the head (usually the first
line) of that item.
Only suitable for diagnostics.
pub fn start_point(&self, sp: Span) -> Span
[src]
pub fn start_point(&self, sp: Span) -> Span
[src]Returns a new span representing just the first character of the given span.
pub fn end_point(&self, sp: Span) -> Span
[src]
pub fn end_point(&self, sp: Span) -> Span
[src]Returns a new span representing just the last character of this span.
pub fn next_point(&self, sp: Span) -> Span
[src]
pub fn next_point(&self, sp: Span) -> Span
[src]Returns a new span representing the next character after the end-point of this span.
pub fn get_source_file(&self, filename: &FileName) -> Option<Lrc<SourceFile>>
[src]
pub fn lookup_byte_offset(&self, bpos: BytePos) -> SourceFileAndBytePos
[src]
pub fn lookup_byte_offset(&self, bpos: BytePos) -> SourceFileAndBytePos
[src]For a global BytePos
, computes the local offset within the containing SourceFile
.
pub fn lookup_source_file_idx(&self, pos: BytePos) -> usize
[src]
pub fn count_lines(&self) -> usize
[src]
pub fn generate_fn_name_span(&self, span: Span) -> Option<Span>
[src]
pub fn generate_local_type_param_snippet(
&self,
span: Span
) -> Option<(Span, String)>
[src]
pub fn generate_local_type_param_snippet(
&self,
span: Span
) -> Option<(Span, String)>
[src]Takes the span of a type parameter in a function signature and try to generate a span for the function name (with generics) and a new snippet for this span with the pointed type parameter as a new local type parameter.
For instance:
// Given span fn my_function(param: T) // ^ Original span // Result fn my_function(param: T) // ^^^^^^^^^^^ Generated span with snippet `my_function<T>`
Attention: The method used is very fragile since it essentially duplicates the work of the
parser. If you need to use this function or something similar, please consider updating the
SourceMap
functions and this function to something more robust.
pub fn ensure_source_file_source_present(
&self,
source_file: Lrc<SourceFile>
) -> bool
[src]
&self,
source_file: Lrc<SourceFile>
) -> bool
pub fn is_imported(&self, sp: Span) -> bool
[src]
Auto Trait Implementations
impl !RefUnwindSafe for SourceMap
impl !Send for SourceMap
impl !Sync for SourceMap
impl Unpin for SourceMap
impl !UnwindSafe for SourceMap
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<'a, T> Captures<'a> for T where
T: ?Sized,
[src]
T: ?Sized,