From a27186636d030c847193ab21c59a1857a1e93785 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 12 Nov 2020 12:09:12 +0100 Subject: Fix attachment of inner doc comments --- crates/syntax/src/ast.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'crates/syntax/src/ast.rs') diff --git a/crates/syntax/src/ast.rs b/crates/syntax/src/ast.rs index 8a0e3d27b..7844f9ed6 100644 --- a/crates/syntax/src/ast.rs +++ b/crates/syntax/src/ast.rs @@ -115,10 +115,10 @@ fn test_doc_comment_none() { } #[test] -fn test_doc_comment_of_items() { +fn test_outer_doc_comment_of_items() { let file = SourceFile::parse( r#" - //! doc + /// doc // non-doc mod foo {} "#, @@ -129,6 +129,21 @@ fn test_doc_comment_of_items() { assert_eq!("doc", module.doc_comment_text().unwrap()); } +#[test] +fn test_inner_doc_comment_of_items() { + let file = SourceFile::parse( + r#" + //! doc + // non-doc + mod foo {} + "#, + ) + .ok() + .unwrap(); + let module = file.syntax().descendants().find_map(Module::cast).unwrap(); + assert!(module.doc_comment_text().is_none()); +} + #[test] fn test_doc_comment_of_statics() { let file = SourceFile::parse( -- cgit v1.2.3