mirror of
				https://github.com/rust-lang/rust-analyzer.git
				synced 2025-11-03 13:13:18 +00:00 
			
		
		
		
	Merge #2150
2150: Attach docs to statics r=matklad a=kjeremy Co-authored-by: kjeremy <kjeremy@gmail.com>
This commit is contained in:
		
						commit
						ed5212e1ac
					
				@ -112,6 +112,20 @@ fn test_doc_comment_of_items() {
 | 
				
			|||||||
    assert_eq!("doc", module.doc_comment_text().unwrap());
 | 
					    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]
 | 
					#[test]
 | 
				
			||||||
fn test_doc_comment_preserves_indents() {
 | 
					fn test_doc_comment_preserves_indents() {
 | 
				
			||||||
    let file = SourceFile::parse(
 | 
					    let file = SourceFile::parse(
 | 
				
			||||||
 | 
				
			|||||||
@ -147,7 +147,7 @@ fn n_attached_trivias<'a>(
 | 
				
			|||||||
) -> usize {
 | 
					) -> usize {
 | 
				
			||||||
    match kind {
 | 
					    match kind {
 | 
				
			||||||
        MACRO_CALL | CONST_DEF | TYPE_ALIAS_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF
 | 
					        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;
 | 
					            let mut res = 0;
 | 
				
			||||||
            for (i, (kind, text)) in trivias.enumerate() {
 | 
					            for (i, (kind, text)) in trivias.enumerate() {
 | 
				
			||||||
                match kind {
 | 
					                match kind {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user