diff options
| author | bors <bors@rust-lang.org> | 2024-02-07 03:33:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-07 03:33:39 +0000 |
| commit | d4f6f9ee6a3b24f2cb97b1a5b82963609b93aa33 (patch) | |
| tree | 87e875c88b08158761df546ea4e88902fbb08d6a /compiler/rustc_span/src/source_map/tests.rs | |
| parent | 586893c7b0adabf5f0a4c155fd86e13cf470e74b (diff) | |
| parent | c7519d42c2664828c98fdb98acab73e9a39b0b97 (diff) | |
| download | rust-d4f6f9ee6a3b24f2cb97b1a5b82963609b93aa33.tar.gz rust-d4f6f9ee6a3b24f2cb97b1a5b82963609b93aa33.zip | |
Auto merge of #118257 - mu001999:dead_code/trait, r=cjgillot
Make traits / trait methods detected by the dead code lint Fixes #118139 and #41883
Diffstat (limited to 'compiler/rustc_span/src/source_map/tests.rs')
| -rw-r--r-- | compiler/rustc_span/src/source_map/tests.rs | 49 |
1 files changed, 2 insertions, 47 deletions
diff --git a/compiler/rustc_span/src/source_map/tests.rs b/compiler/rustc_span/src/source_map/tests.rs index 5788d11ed43..51f8aa04e8a 100644 --- a/compiler/rustc_span/src/source_map/tests.rs +++ b/compiler/rustc_span/src/source_map/tests.rs @@ -1,5 +1,7 @@ use super::*; +use rustc_data_structures::sync::FreezeLock; + fn init_source_map() -> SourceMap { let sm = SourceMap::new(FilePathMapping::empty()); sm.new_source_file(PathBuf::from("blork.rs").into(), "first line.\nsecond line".to_string()); @@ -263,53 +265,6 @@ fn t10() { ); } -/// Returns the span corresponding to the `n`th occurrence of `substring` in `source_text`. -trait SourceMapExtension { - fn span_substr( - &self, - file: &Lrc<SourceFile>, - source_text: &str, - substring: &str, - n: usize, - ) -> Span; -} - -impl SourceMapExtension for SourceMap { - fn span_substr( - &self, - file: &Lrc<SourceFile>, - source_text: &str, - substring: &str, - n: usize, - ) -> Span { - eprintln!( - "span_substr(file={:?}/{:?}, substring={:?}, n={})", - file.name, file.start_pos, substring, n - ); - let mut i = 0; - let mut hi = 0; - loop { - let offset = source_text[hi..].find(substring).unwrap_or_else(|| { - panic!( - "source_text `{}` does not have {} occurrences of `{}`, only {}", - source_text, n, substring, i - ); - }); - let lo = hi + offset; - hi = lo + substring.len(); - if i == n { - let span = Span::with_root_ctxt( - BytePos(lo as u32 + file.start_pos.0), - BytePos(hi as u32 + file.start_pos.0), - ); - assert_eq!(&self.span_to_snippet(span).unwrap()[..], substring); - return span; - } - i += 1; - } - } -} - // Takes a unix-style path and returns a platform specific path. fn path(p: &str) -> PathBuf { path_str(p).into() |
