SourceMap in rustc_span::source_map - Rust (original) (raw)

pub struct SourceMap {
    files: RwLock<SourceMapFiles>,
    file_loader: IntoDynSyncSend<Box<dyn FileLoader + Sync + Send>>,
    path_mapping: FilePathMapping,
    hash_kind: SourceFileHashAlgorithm,
    checksum_hash_kind: Option<SourceFileHashAlgorithm>,
}

The algorithm used for hashing the contents of each source file.

Similar to hash_kind, however this algorithm is used for checksums to determine if a crate is fresh.cargo is the primary user of these.

If this is equal to hash_kind then the checksum won’t be computed twice.

Source§

Source

Source

Source

Source

Source

Source

Loads source file as a binary blob.

Unlike load_file, guarantees that no normalization like BOM-removal takes place.

Source

Source

Source

Source

Creates a new SourceFile. If a file already exists in the SourceMap with the same ID, that file is returned unmodified.

Source

Source

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.

Source

If there is a doctest offset, applies it to the line.

Source

Return the SourceFile that contains the given BytePos

Source

Looks up source information about a BytePos.

Source

If the corresponding SourceFile is empty, does not return a line number.

Source

Source

Source

Format the span location suitable for embedding in build artifacts

Source

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.

Source

Source

Source

Source

Source

Source

Source

Extracts 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.

Source

Source

Returns the source snippet as String corresponding to the given Span.

Source

Source

Source

Returns the source snippet as String before the given Span.

Source

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.

Source

Extends the given Span to just before the previous occurrence of c. Return the same span if an error occurred while retrieving the code snippet.

Source

Extends the given Span to just after the previous occurrence of pat when surrounded by whitespace. Returns None if the pattern could not be found or if an error occurred while retrieving the code snippet.

Source

Returns the source snippet as String after the given Span.

Source

Extends the given Span while the next character matches the predicate

Source

Extends the span to include any trailing whitespace, or returns the original span if a SpanSnippetError was encountered.

Source

Extends the given Span to previous character while the previous character matches the predicate

Source

Extends the given Span to just before the next occurrence of c.

Source

Extends the given Span to contain the entire line it is on.

Source

Given a Span, tries to get a shorter span ending before the first occurrence of char c.

Source

Given a ‘Span’, tries to tell if it’s wrapped by “<>” or “()” the algorithm searches if the next character is ‘>’ or ‘)’ after skipping white space then searches the previous character to match ‘<’ or ‘(’ after skipping white space return true if wrapped by ‘<>’ or ‘()’

Source

Given a Span, tries to get a shorter span ending just after the first occurrence of char c.

Source

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.

Source

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.

Source

Given a Span, gets a shorter one until predicate yields false.

Source

Given a Span, return a span ending in the closest {. This is useful when you have aSpan enclosing a whole item but we need to point at only the head (usually the first line) of that item.

Only suitable for diagnostics.

Source

Returns a new span representing just the first character of the given span.

Source

Returns a new span representing just the last character of this span.

Source

Returns a new span representing the next character after the end-point of this span. Special cases:

Source

Check whether span is followed by some specified expected string in limit scope

Source

Finds the width of the character, either before or after the end of provided span, depending on the forwards parameter.

Source

Source

For a global BytePos, computes the local offset within the containing SourceFile.

Source

Returns the index of the SourceFile (in self.files) that contains pos. This index is guaranteed to be valid for the lifetime of this SourceMap, since source_files is a MonotonicVec

Source

Source

Source

Source

Gets the span of a statement. If the statement is a macro expansion, the span in the context of the block span is found. The trailing semicolon is included on a best-effort basis.

Source

Tries to find the span of the semicolon of a macro call statement. The input must be the call site span of a statement from macro expansion.

//       v output
   mac!();
// ^^^^^^ input

§

§

§

§

§

§

§

§

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: 120 bytes