Repository: sharkdp/bat (language: rust)

Issue:
Warn at asset building time when a syntax definition context reference can't be resolved
It would be great to make use of the new syntect API to detect when a syntax definition has some context references (specifically push/set targets - missing includes are not such a problem and can be just treated as warnings) which couldn't be linked/resolved and fail the CI build. https://github.com/sharkdp/bat/issues/915#issuecomment-823581511


Discussion / hints:
Sounds great! Thank you for adding this in `syntect`!

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index aaa83b5068..7feb2f4f96 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -381,9 +381,9 @@ dependencies = [
 
 [[package]]
 name = "fancy-regex"
-version = "0.3.5"
+version = "0.7.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae91abf6555234338687bb47913978d275539235fcb77ba9863b779090b42b14"
+checksum = "9d6b8560a05112eb52f04b00e5d3790c0dd75d9d980eb8a122fb23b92a623ccf"
 dependencies = [
  "bit-set",
  "regex",
@@ -1088,9 +1088,9 @@ dependencies = [
 
 [[package]]
 name = "syntect"
-version = "4.5.0"
+version = "4.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2bfac2b23b4d049dc9a89353b4e06bbc85a8f42020cccbe5409a115cf19031e5"
+checksum = "8b20815bbe80ee0be06e6957450a841185fcf690fe0178f14d77a05ce2caa031"
 dependencies = [
  "bincode",
  "bitflags",
diff --git a/Cargo.toml b/Cargo.toml
index f3ff24a20a..633777241e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -60,7 +60,7 @@ optional = true
 default-features = false
 
 [dependencies.syntect]
-version = "4.5.0"
+version = "4.6.0"
 default-features = false
 features = ["parsing", "yaml-load", "dump-load", "dump-create"]
 
diff --git a/src/assets.rs b/src/assets.rs
index 72e85742bd..57c28c3178 100644
--- a/src/assets.rs
+++ b/src/assets.rs
@@ -111,8 +111,17 @@ impl HighlightingAssets {
             );
         }
 
+        let syntax_set = syntax_set_builder.build();
+        let missing_contexts = syntax_set.find_unlinked_contexts();
+        if !missing_contexts.is_empty() {
+            println!("Some referenced contexts could not be found!");
+            for context in missing_contexts {
+                println!("- {}", context);
+            }
+        }
+
         Ok(HighlightingAssets::new(
-            Some(syntax_set_builder.build()),
+            Some(syntax_set),
             None,
             theme_set,
         ))


Test patch: