Struct syntax::codemap::CodeMap [−][src]
pub struct CodeMap { pub(super) files: Lock<CodeMapFiles>, file_loader: Box<FileLoader + Sync + Send>, path_mapping: FilePathMapping, doctest_offset: Option<(FileName, isize)>, }
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Fields
files: Lock<CodeMapFiles>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
file_loader: Box<FileLoader + Sync + Send>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
path_mapping: FilePathMapping
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
doctest_offset: Option<(FileName, isize)>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
In case we are in a doctest, replace all file names with the PathBuf, and add the given offsets to the line info
Methods
impl CodeMap
[src]
impl CodeMap
pub fn new(path_mapping: FilePathMapping) -> CodeMap
[src]
pub fn new(path_mapping: FilePathMapping) -> CodeMap
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn new_doctest(
path_mapping: FilePathMapping,
file: FileName,
line: isize
) -> CodeMap
[src]
pub fn new_doctest(
path_mapping: FilePathMapping,
file: FileName,
line: isize
) -> CodeMap
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn with_file_loader(
file_loader: Box<FileLoader + Sync + Send>,
path_mapping: FilePathMapping
) -> CodeMap
[src]
pub fn with_file_loader(
file_loader: Box<FileLoader + Sync + Send>,
path_mapping: FilePathMapping
) -> CodeMap
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn path_mapping(&self) -> &FilePathMapping
[src]
pub fn path_mapping(&self) -> &FilePathMapping
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn file_exists(&self, path: &Path) -> bool
[src]
pub fn file_exists(&self, path: &Path) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn load_file(&self, path: &Path) -> Result<Lrc<FileMap>>
[src]
pub fn load_file(&self, path: &Path) -> Result<Lrc<FileMap>>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn files(&self) -> LockGuard<Vec<Lrc<FileMap>>>
[src]
pub fn files(&self) -> LockGuard<Vec<Lrc<FileMap>>>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn filemap_by_stable_id(
&self,
stable_id: StableFilemapId
) -> Option<Lrc<FileMap>>
[src]
pub fn filemap_by_stable_id(
&self,
stable_id: StableFilemapId
) -> Option<Lrc<FileMap>>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn next_start_pos(&self) -> usize
[src]
fn next_start_pos(&self) -> usize
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn new_filemap(&self, filename: FileName, src: String) -> Lrc<FileMap>
[src]
pub fn new_filemap(&self, filename: FileName, src: String) -> Lrc<FileMap>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Creates a new filemap. This does not ensure that only one FileMap exists per file name.
pub fn new_imported_filemap(
&self,
filename: FileName,
name_was_remapped: bool,
crate_of_origin: u32,
src_hash: u128,
name_hash: u128,
source_len: usize,
file_local_lines: Vec<BytePos>,
file_local_multibyte_chars: Vec<MultiByteChar>,
file_local_non_narrow_chars: Vec<NonNarrowChar>
) -> Lrc<FileMap>
[src]
pub fn new_imported_filemap(
&self,
filename: FileName,
name_was_remapped: bool,
crate_of_origin: u32,
src_hash: u128,
name_hash: u128,
source_len: usize,
file_local_lines: Vec<BytePos>,
file_local_multibyte_chars: Vec<MultiByteChar>,
file_local_non_narrow_chars: Vec<NonNarrowChar>
) -> Lrc<FileMap>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Allocates a new FileMap representing a source file from an external crate. The source code of such an "imported filemap" is not available, but we still know enough to generate accurate debuginfo location information for things inlined from other crates.
pub fn mk_substr_filename(&self, sp: Span) -> String
[src]
pub fn mk_substr_filename(&self, sp: Span) -> String
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn doctest_offset_line(&self, orig: usize) -> usize
[src]
pub fn doctest_offset_line(&self, orig: usize) -> usize
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc
[src]
pub fn lookup_char_pos(&self, pos: BytePos) -> Loc
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Lookup source information about a BytePos
pub fn lookup_line(&self, pos: BytePos) -> Result<FileMapAndLine, Lrc<FileMap>>
[src]
pub fn lookup_line(&self, pos: BytePos) -> Result<FileMapAndLine, Lrc<FileMap>>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt
[src]
pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>
[src]
pub fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns Some(span)
, a union of the lhs and rhs span. The lhs must precede the rhs. If
there are gaps between lhs and rhs, the resulting union will cross these gaps.
For this to work, the spans have to be:
- the ctxt of both spans much match
- the lhs span needs to end on the same line the rhs span begins
- the lhs span must start at or before the rhs span
pub fn span_to_string(&self, sp: Span) -> String
[src]
pub fn span_to_string(&self, sp: Span) -> String
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn span_to_filename(&self, sp: Span) -> FileName
[src]
pub fn span_to_filename(&self, sp: Span) -> FileName
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn span_to_unmapped_path(&self, sp: Span) -> FileName
[src]
pub fn span_to_unmapped_path(&self, sp: Span) -> FileName
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn is_multiline(&self, sp: Span) -> bool
[src]
pub fn is_multiline(&self, sp: Span) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn span_to_lines(&self, sp: Span) -> FileLinesResult
[src]
pub fn span_to_lines(&self, sp: Span) -> FileLinesResult
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn span_to_source<F>(
&self,
sp: Span,
extract_source: F
) -> Result<String, SpanSnippetError> where
F: Fn(&str, usize, usize) -> String,
[src]
fn span_to_source<F>(
&self,
sp: Span,
extract_source: F
) -> Result<String, SpanSnippetError> where
F: Fn(&str, usize, usize) -> String,
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Extract the source surrounding the given Span
using the extract_source
function. The
extract function takes three arguments: a string slice containing the source, an index in
the slice for the beginning of the span and an index in the slice for the end of the span.
pub fn span_to_snippet(&self, sp: Span) -> Result<String, SpanSnippetError>
[src]
pub fn span_to_snippet(&self, sp: Span) -> Result<String, SpanSnippetError>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Return the source snippet as String
corresponding to the given Span
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>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Return the source snippet as String
before the given Span
pub fn span_extend_to_prev_char(&self, sp: Span, c: char) -> Span
[src]
pub fn span_extend_to_prev_char(&self, sp: Span, c: char) -> Span
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Extend 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
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Extend the given Span
to just after the previous occurrence of pat
when surrounded by
whitespace. Return the same span if no character could be found or if an error occurred
while retrieving the code snippet.
pub fn span_until_char(&self, sp: Span, c: char) -> Span
[src]
pub fn span_until_char(&self, sp: Span, c: char) -> Span
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Given a Span
, try to get a shorter span ending before the first occurrence of c
char
pub fn span_through_char(&self, sp: Span, c: char) -> Span
[src]
pub fn span_through_char(&self, sp: Span, c: char) -> Span
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Given a Span
, try 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
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Given a Span
, get 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
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Given a Span
, get 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,
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Given a Span
, get a shorter one until predicate
yields false.
pub fn def_span(&self, sp: Span) -> Span
[src]
pub fn def_span(&self, sp: Span) -> Span
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn start_point(&self, sp: Span) -> Span
[src]
pub fn start_point(&self, sp: Span) -> Span
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns a new span representing just the start-point of this span
pub fn end_point(&self, sp: Span) -> Span
[src]
pub fn end_point(&self, sp: Span) -> Span
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns a new span representing just the end-point of this span
pub fn next_point(&self, sp: Span) -> Span
[src]
pub fn next_point(&self, sp: Span) -> Span
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Returns a new span representing the next character after the end-point of this span
fn find_width_of_character_at_span(&self, sp: Span, forwards: bool) -> u32
[src]
fn find_width_of_character_at_span(&self, sp: Span, forwards: bool) -> u32
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Finds the width of a character, either before or after the provided span.
pub fn get_filemap(&self, filename: &FileName) -> Option<Lrc<FileMap>>
[src]
pub fn get_filemap(&self, filename: &FileName) -> Option<Lrc<FileMap>>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos
[src]
pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
For a global BytePos compute the local offset within the containing FileMap
pub fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos
[src]
pub fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Converts an absolute BytePos to a CharPos relative to the filemap.
pub fn lookup_filemap_idx(&self, pos: BytePos) -> usize
[src]
pub fn lookup_filemap_idx(&self, pos: BytePos) -> usize
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn count_lines(&self) -> usize
[src]
pub fn count_lines(&self) -> usize
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
pub fn generate_fn_name_span(&self, span: Span) -> Option<Span>
[src]
pub fn generate_fn_name_span(&self, span: Span) -> Option<Span>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
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)>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
Take 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 codemap functions and this function to something more robust.
Trait Implementations
impl CodeMapper for CodeMap
[src]
impl CodeMapper for CodeMap
fn lookup_char_pos(&self, pos: BytePos) -> Loc
[src]
fn lookup_char_pos(&self, pos: BytePos) -> Loc
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn span_to_lines(&self, sp: Span) -> FileLinesResult
[src]
fn span_to_lines(&self, sp: Span) -> FileLinesResult
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn span_to_string(&self, sp: Span) -> String
[src]
fn span_to_string(&self, sp: Span) -> String
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn span_to_filename(&self, sp: Span) -> FileName
[src]
fn span_to_filename(&self, sp: Span) -> FileName
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>
[src]
fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn call_span_if_macro(&self, sp: Span) -> Span
[src]
fn call_span_if_macro(&self, sp: Span) -> Span
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn ensure_filemap_source_present(&self, file_map: Lrc<FileMap>) -> bool
[src]
fn ensure_filemap_source_present(&self, file_map: Lrc<FileMap>) -> bool
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
fn doctest_offset_line(&self, line: usize) -> usize
[src]
fn doctest_offset_line(&self, line: usize) -> usize
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?