Skip to content

Commit 5d23d47

Browse files
committed
Rust: skip comments and token trees when extracting library files
1 parent 977a197 commit 5d23d47

File tree

1 file changed

+4
-1
lines changed
  • rust/extractor/src/translate

1 file changed

+4
-1
lines changed

rust/extractor/src/translate/base.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl<'a> Translator<'a> {
272272
) {
273273
for child in children {
274274
if let NodeOrToken::Token(token) = child {
275-
if token.kind() == SyntaxKind::COMMENT {
275+
if token.kind() == SyntaxKind::COMMENT && self.source_kind == SourceKind::Source {
276276
let label = self.trap.emit(generated::Comment {
277277
id: TrapId::Star,
278278
parent: parent_label,
@@ -655,6 +655,9 @@ impl<'a> Translator<'a> {
655655
pub(crate) fn should_be_excluded(&self, item: &impl ast::AstNode) -> bool {
656656
if self.source_kind == SourceKind::Library {
657657
let syntax = item.syntax();
658+
if syntax.kind() == SyntaxKind::TOKEN_TREE {
659+
return true;
660+
}
658661
if syntax
659662
.parent()
660663
.and_then(Fn::cast)

0 commit comments

Comments
 (0)