aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/dev/lsp-extensions.md10
-rw-r--r--xtask/tests/tidy.rs45
2 files changed, 55 insertions, 0 deletions
diff --git a/docs/dev/lsp-extensions.md b/docs/dev/lsp-extensions.md
index 3f861f3e0..43a69d6ce 100644
--- a/docs/dev/lsp-extensions.md
+++ b/docs/dev/lsp-extensions.md
@@ -1,3 +1,13 @@
1<!---
2lsp_ext.rs hash: 286f8bbac885531a
3
4If you need to change the above hash to make the test pass, please check if you
5need to adjust this doc as well and ping this issue:
6
7 https://github.com/rust-analyzer/rust-analyzer/issues/4604
8
9--->
10
1# LSP Extensions 11# LSP Extensions
2 12
3This document describes LSP extensions used by rust-analyzer. 13This document describes LSP extensions used by rust-analyzer.
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index 0c233f87d..b3bb9d543 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -45,6 +45,41 @@ fn smoke_test_docs_generation() {
45} 45}
46 46
47#[test] 47#[test]
48fn check_lsp_extensions_docs() {
49 let expected_hash = {
50 let lsp_ext_rs =
51 fs2::read_to_string(project_root().join("crates/rust-analyzer/src/lsp_ext.rs"))
52 .unwrap();
53 stable_hash(lsp_ext_rs.as_str())
54 };
55
56 let actual_hash = {
57 let lsp_extensions_md =
58 fs2::read_to_string(project_root().join("docs/dev/lsp-extensions.md")).unwrap();
59 let text = lsp_extensions_md
60 .lines()
61 .find_map(|line| line.strip_prefix("lsp_ext.rs hash:"))
62 .unwrap()
63 .trim();
64 u64::from_str_radix(text, 16).unwrap()
65 };
66
67 if actual_hash != expected_hash {
68 panic!(
69 "
70lsp_ext.rs was changed without touching lsp-extensions.md.
71
72Expected hash: {:x}
73Actual hash: {:x}
74
75Please adjust docs/dev/lsp-extensions.md.
76",
77 expected_hash, actual_hash
78 )
79 }
80}
81
82#[test]
48fn rust_files_are_tidy() { 83fn rust_files_are_tidy() {
49 let mut tidy_docs = TidyDocs::default(); 84 let mut tidy_docs = TidyDocs::default();
50 for path in rust_files(&project_root().join("crates")) { 85 for path in rust_files(&project_root().join("crates")) {
@@ -280,3 +315,13 @@ fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool {
280 .filter_map(|it| it.as_os_str().to_str()) 315 .filter_map(|it| it.as_os_str().to_str())
281 .any(|it| dirs_to_exclude.contains(&it)) 316 .any(|it| dirs_to_exclude.contains(&it))
282} 317}
318
319#[allow(deprecated)]
320fn stable_hash(text: &str) -> u64 {
321 use std::hash::{Hash, Hasher, SipHasher};
322
323 let text = text.replace('\r', "");
324 let mut hasher = SipHasher::default();
325 text.hash(&mut hasher);
326 hasher.finish()
327}