diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index a12da5be2ab4..1ec9881b9808 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -112,6 +112,20 @@ fn test_doc_comment_of_items() { assert_eq!("doc", module.doc_comment_text().unwrap()); } +#[test] +fn test_doc_comment_of_statics() { + let file = SourceFile::parse( + r#" + /// Number of levels + static LEVELS: i32 = 0; + "#, + ) + .ok() + .unwrap(); + let st = file.syntax().descendants().find_map(StaticDef::cast).unwrap(); + assert_eq!("Number of levels", st.doc_comment_text().unwrap()); +} + #[test] fn test_doc_comment_preserves_indents() { let file = SourceFile::parse( diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index 142164316360..c36756d6c37c 100644 --- a/crates/ra_syntax/src/parsing/text_tree_sink.rs +++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs @@ -147,7 +147,7 @@ fn n_attached_trivias<'a>( ) -> usize { match kind { MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF - | TRAIT_DEF | MODULE | RECORD_FIELD_DEF => { + | TRAIT_DEF | MODULE | RECORD_FIELD_DEF | STATIC_DEF => { let mut res = 0; for (i, (kind, text)) in trivias.enumerate() { match kind {