diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-11-15 08:32:31 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-11-15 08:45:43 -0500 |
| commit | 3f93ffc3334b77cc9025f68dfcea92098987abf3 (patch) | |
| tree | 8e532f41f4ddb5f1203d29c4b17114f70694ad3a /src/librustc_errors/lib.rs | |
| parent | 942f0a6f7a82facc30501232e28759cab54a21b3 (diff) | |
| download | rust-3f93ffc3334b77cc9025f68dfcea92098987abf3.tar.gz rust-3f93ffc3334b77cc9025f68dfcea92098987abf3.zip | |
Remove SourceMapper trait
SourceMap is now in the root of all rustc-specific crates, syntax_pos, so there's no need for the trait object to decouple the dependencies between librustc_errors and libsyntax as was needed previously.
Diffstat (limited to 'src/librustc_errors/lib.rs')
| -rw-r--r-- | src/librustc_errors/lib.rs | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index ee35d23af34..1a6ac328a47 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -18,6 +18,8 @@ use registry::Registry; use rustc_data_structures::sync::{self, Lrc, Lock}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::stable_hasher::StableHasher; +use syntax_pos::source_map::SourceMap; +use syntax_pos::{Loc, Span, MultiSpan}; use std::borrow::Cow; use std::cell::Cell; @@ -36,17 +38,6 @@ pub mod registry; mod styled_buffer; mod lock; -use syntax_pos::{ - BytePos, - FileLinesResult, - FileName, - Loc, - MultiSpan, - SourceFile, - Span, - SpanSnippetError, -}; - pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a>>; // `PResult` is used a lot. Make sure it doesn't unintentionally get bigger. @@ -150,26 +141,12 @@ pub struct SubstitutionPart { pub snippet: String, } -pub type SourceMapperDyn = dyn SourceMapper + sync::Send + sync::Sync; - -pub trait SourceMapper { - fn lookup_char_pos(&self, pos: BytePos) -> Loc; - fn span_to_lines(&self, sp: Span) -> FileLinesResult; - fn span_to_string(&self, sp: Span) -> String; - fn span_to_snippet(&self, sp: Span) -> Result<String, SpanSnippetError>; - fn span_to_filename(&self, sp: Span) -> FileName; - fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>; - fn call_span_if_macro(&self, sp: Span) -> Span; - fn ensure_source_file_source_present(&self, source_file: Lrc<SourceFile>) -> bool; - fn doctest_offset_line(&self, file: &FileName, line: usize) -> usize; -} - impl CodeSuggestion { /// Returns the assembled code suggestions, whether they should be shown with an underline /// and whether the substitution only differs in capitalization. pub fn splice_lines( &self, - cm: &SourceMapperDyn, + cm: &SourceMap, ) -> Vec<(String, Vec<SubstitutionPart>, bool)> { use syntax_pos::{CharPos, Pos}; @@ -376,7 +353,7 @@ impl Handler { color_config: ColorConfig, can_emit_warnings: bool, treat_err_as_bug: Option<usize>, - cm: Option<Lrc<SourceMapperDyn>>, + cm: Option<Lrc<SourceMap>>, ) -> Self { Self::with_tty_emitter_and_flags( color_config, @@ -391,7 +368,7 @@ impl Handler { pub fn with_tty_emitter_and_flags( color_config: ColorConfig, - cm: Option<Lrc<SourceMapperDyn>>, + cm: Option<Lrc<SourceMap>>, flags: HandlerFlags, ) -> Self { let emitter = Box::new(EmitterWriter::stderr( |
