|
1 | 1 | use super::*; |
2 | 2 |
|
| 3 | +use rustc_data_structures::sync::FreezeLock; |
| 4 | + |
3 | 5 | fn init_source_map() -> SourceMap { |
4 | 6 | let sm = SourceMap::new(FilePathMapping::empty()); |
5 | 7 | sm.new_source_file(PathBuf::from("blork.rs").into(), "first line.\nsecond line".to_string()); |
@@ -263,53 +265,6 @@ fn t10() { |
263 | 265 | ); |
264 | 266 | } |
265 | 267 |
|
266 | | -/// Returns the span corresponding to the `n`th occurrence of `substring` in `source_text`. |
267 | | -trait SourceMapExtension { |
268 | | - fn span_substr( |
269 | | - &self, |
270 | | - file: &Lrc<SourceFile>, |
271 | | - source_text: &str, |
272 | | - substring: &str, |
273 | | - n: usize, |
274 | | - ) -> Span; |
275 | | -} |
276 | | - |
277 | | -impl SourceMapExtension for SourceMap { |
278 | | - fn span_substr( |
279 | | - &self, |
280 | | - file: &Lrc<SourceFile>, |
281 | | - source_text: &str, |
282 | | - substring: &str, |
283 | | - n: usize, |
284 | | - ) -> Span { |
285 | | - eprintln!( |
286 | | - "span_substr(file={:?}/{:?}, substring={:?}, n={})", |
287 | | - file.name, file.start_pos, substring, n |
288 | | - ); |
289 | | - let mut i = 0; |
290 | | - let mut hi = 0; |
291 | | - loop { |
292 | | - let offset = source_text[hi..].find(substring).unwrap_or_else(|| { |
293 | | - panic!( |
294 | | - "source_text `{}` does not have {} occurrences of `{}`, only {}", |
295 | | - source_text, n, substring, i |
296 | | - ); |
297 | | - }); |
298 | | - let lo = hi + offset; |
299 | | - hi = lo + substring.len(); |
300 | | - if i == n { |
301 | | - let span = Span::with_root_ctxt( |
302 | | - BytePos(lo as u32 + file.start_pos.0), |
303 | | - BytePos(hi as u32 + file.start_pos.0), |
304 | | - ); |
305 | | - assert_eq!(&self.span_to_snippet(span).unwrap()[..], substring); |
306 | | - return span; |
307 | | - } |
308 | | - i += 1; |
309 | | - } |
310 | | - } |
311 | | -} |
312 | | - |
313 | 268 | // Takes a unix-style path and returns a platform specific path. |
314 | 269 | fn path(p: &str) -> PathBuf { |
315 | 270 | path_str(p).into() |
|
0 commit comments