Skip to content

Commit 7bb0c00

Browse files
committed
docgen: skip over cpp attributes before decl
1 parent abb1e40 commit 7bb0c00

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/src/bin/docgen/main.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,16 @@ fn comment_and_requirement(
187187
node: Node,
188188
src: &[u8],
189189
) -> Result<(Option<Comment>, Option<Feature>), Box<dyn Error>> {
190-
let maybe_comment = Comment::new(node, src).ok();
190+
let mut maybe_comment = Comment::new(node, src).ok();
191+
192+
// If node wasn't a comment, see if it was an expression_statement
193+
// that itself was preceded by a comment. This skips over
194+
// expression-like preprocessor attributes on function decls.
195+
if let (None, "expression_statement", Some(prev)) =
196+
(&maybe_comment, node.kind(), node.prev_sibling())
197+
{
198+
maybe_comment = Comment::new(prev, src).ok();
199+
}
191200

192201
// If prev wasn't a comment, see if it was a feature requirement.
193202
if maybe_comment.is_none() {

0 commit comments

Comments
 (0)