Auto merge of #115418 - Zoxc:freeze-source, r=oli-obk

Use `Freeze` for `SourceFile`

This uses the `Freeze` type in `SourceFile` to let accessing `external_src` and `lines` be lock-free.

Behavior of `add_external_src` is changed to set `ExternalSourceKind::AbsentErr` on a hash mismatch which matches the documentation. `ExternalSourceKind::Unneeded` was removed as it's unused.

Based on https://github.com/rust-lang/rust/pull/115401.
This commit is contained in:
bors 2023-09-08 17:20:23 +00:00
commit c41e7794cd

View File

@ -81,7 +81,7 @@ pub(crate) fn get_span_loc(
match tcx.sess.source_map().lookup_line(span.lo()) { match tcx.sess.source_map().lookup_line(span.lo()) {
Ok(SourceFileAndLine { sf: file, line }) => { Ok(SourceFileAndLine { sf: file, line }) => {
let line_pos = file.lines(|lines| lines[line]); let line_pos = file.lines()[line];
let col = file.relative_position(span.lo()) - line_pos; let col = file.relative_position(span.lo()) - line_pos;
(file, u64::try_from(line).unwrap() + 1, u64::from(col.to_u32()) + 1) (file, u64::try_from(line).unwrap() + 1, u64::from(col.to_u32()) + 1)