@@ -44,6 +44,41 @@ fn smoke_test_docs_generation() {
44
44
codegen:: generate_feature_docs ( Mode :: Overwrite ) . unwrap ( ) ;
45
45
}
46
46
47
+ #[ test]
48
+ fn 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
+ "
70
+ lsp_ext.rs was changed without touching lsp-extensions.md.
71
+
72
+ Expected hash: {:x}
73
+ Actual hash: {:x}
74
+
75
+ Please adjust docs/dev/lsp-extensions.md.
76
+ " ,
77
+ expected_hash, actual_hash
78
+ )
79
+ }
80
+ }
81
+
47
82
#[ test]
48
83
fn rust_files_are_tidy ( ) {
49
84
let mut tidy_docs = TidyDocs :: default ( ) ;
@@ -280,3 +315,13 @@ fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool {
280
315
. filter_map ( |it| it. as_os_str ( ) . to_str ( ) )
281
316
. any ( |it| dirs_to_exclude. contains ( & it) )
282
317
}
318
+
319
+ #[ allow( deprecated) ]
320
+ fn 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
+ }
0 commit comments