HighlightingAssets: Make .syntaxes() and syntax_for_file_name() failable

Or rather, introduce new versions of these methods and deprecate the old ones.

This is preparation to enable robust and user-friendly support for lazy-loading.
With lazy-loading, we don't know if the SyntaxSet is valid until after we try to
use it, so wherever we try to use it, we need to return a Result. See discussion
about panics in #1747.
This commit is contained in:
Martin Nordholts committed 2021-07-29 08:26:18 +02:00
1 parent c0e09662b4
commit a81009607a
6 files changed
+95 -39

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ fn no_duplicate_extensions() {
let mut extensions = HashSet::new();
for syntax in assets.syntaxes() {
for syntax in assets.get_syntaxes().expect("this is a #[test]") {
for extension in &syntax.file_extensions {
assert!(
KNOWN_EXCEPTIONS.contains(&extension.as_str()) || extensions.insert(extension),