Fix a panic when parsing empty file (#11314)

The previous implementation presumed that if files were given, they had
contents. The change makes the fallback to permanent files uniform.

Fix #11256
This commit is contained in:
Andrej Kolchin
2024-02-08 00:47:44 +00:00
committed by GitHub
parent 3633772d52
commit fb7f6fc08b
2 changed files with 15 additions and 5 deletions

View File

@ -355,11 +355,10 @@ impl<'a> StateWorkingSet<'a> {
return &contents[begin..end];
}
}
} else {
return self.permanent_state.get_span_contents(span);
}
panic!("internal error: missing span contents in file cache")
// if no files with span were found, fall back on permanent ones
return self.permanent_state.get_span_contents(span);
}
pub fn enter_scope(&mut self) {