diff --git a/crates/oxc_ast/src/ast/comment.rs b/crates/oxc_ast/src/ast/comment.rs index 0b47c39420926..3a6bbbc5c39ac 100644 --- a/crates/oxc_ast/src/ast/comment.rs +++ b/crates/oxc_ast/src/ast/comment.rs @@ -46,7 +46,7 @@ pub enum CommentPosition { #[ast] #[generate_derive(CloneIn, ContentEq)] #[derive(Debug, Default, Clone, Copy, Eq, PartialEq)] -pub enum CommentAnnotation { +pub enum CommentContent { /// No Annotation #[default] None = 0, @@ -60,27 +60,31 @@ pub enum CommentAnnotation { /// Jsdoc = 2, + /// A jsdoc containing legal annotation. + /// `/** @preserve */` + JsdocLegal = 3, + /// `/* #__PURE__ */` /// - Pure = 3, + Pure = 4, /// `/* #__NO_SIDE_EFFECTS__ */` - NoSideEffects = 4, + NoSideEffects = 5, /// Webpack magic comment /// e.g. `/* webpackChunkName */` /// - Webpack = 5, + Webpack = 6, /// Vite comment /// e.g. `/* @vite-ignore */` /// - Vite = 6, + Vite = 7, /// Code Coverage Ignore /// `v8 ignore`, `c8 ignore`, `node:coverage`, `istanbul ignore` /// - CoverageIgnore = 7, + CoverageIgnore = 8, } bitflags! { @@ -144,9 +148,9 @@ pub struct Comment { #[estree(skip)] pub newlines: CommentNewlines, - /// Comment Annotation + /// Content of the comment #[estree(skip)] - pub annotation: CommentAnnotation, + pub content: CommentContent, } impl Comment { @@ -160,7 +164,7 @@ impl Comment { kind, position: CommentPosition::Trailing, newlines: CommentNewlines::None, - annotation: CommentAnnotation::None, + content: CommentContent::None, } } @@ -196,16 +200,23 @@ impl Comment { self.position == CommentPosition::Trailing } + /// Is comment without a special meaning. + #[inline] + pub fn is_normal(self) -> bool { + self.content == CommentContent::None + } + /// Is comment with special meaning. #[inline] pub fn is_annotation(self) -> bool { - self.annotation != CommentAnnotation::None + self.content != CommentContent::None && self.content != CommentContent::Legal } /// Returns `true` if this comment is a JSDoc comment. Implies `is_leading` and `is_block`. #[inline] pub fn is_jsdoc(self) -> bool { - self.annotation == CommentAnnotation::Jsdoc && self.is_leading() + matches!(self.content, CommentContent::Jsdoc | CommentContent::JsdocLegal) + && self.is_leading() } /// Legal comments @@ -216,37 +227,38 @@ impl Comment { /// #[inline] pub fn is_legal(self) -> bool { - self.annotation == CommentAnnotation::Legal && self.is_leading() + matches!(self.content, CommentContent::Legal | CommentContent::JsdocLegal) + && self.is_leading() } /// Is `/* @__PURE__*/`. #[inline] pub fn is_pure(self) -> bool { - self.annotation == CommentAnnotation::Pure + self.content == CommentContent::Pure } /// Is `/* @__NO_SIDE_EFFECTS__*/`. #[inline] pub fn is_no_side_effects(self) -> bool { - self.annotation == CommentAnnotation::NoSideEffects + self.content == CommentContent::NoSideEffects } /// Is webpack magic comment. #[inline] pub fn is_webpack(self) -> bool { - self.annotation == CommentAnnotation::Webpack + self.content == CommentContent::Webpack } /// Is vite special comment. #[inline] pub fn is_vite(self) -> bool { - self.annotation == CommentAnnotation::Vite + self.content == CommentContent::Vite } /// Is coverage ignore comment. #[inline] pub fn is_coverage_ignore(self) -> bool { - self.annotation == CommentAnnotation::CoverageIgnore && self.is_leading() + self.content == CommentContent::CoverageIgnore && self.is_leading() } /// Returns `true` if this comment is preceded by a newline. diff --git a/crates/oxc_ast/src/generated/assert_layouts.rs b/crates/oxc_ast/src/generated/assert_layouts.rs index cb2f24a703564..3d7fbf5be8ab8 100644 --- a/crates/oxc_ast/src/generated/assert_layouts.rs +++ b/crates/oxc_ast/src/generated/assert_layouts.rs @@ -1578,8 +1578,8 @@ const _: () = { assert!(size_of::() == 1); assert!(align_of::() == 1); - assert!(size_of::() == 1); - assert!(align_of::() == 1); + assert!(size_of::() == 1); + assert!(align_of::() == 1); // Padding: 0 bytes assert!(size_of::() == 1); @@ -1593,7 +1593,7 @@ const _: () = { assert!(offset_of!(Comment, kind) == 12); assert!(offset_of!(Comment, position) == 13); assert!(offset_of!(Comment, newlines) == 14); - assert!(offset_of!(Comment, annotation) == 15); + assert!(offset_of!(Comment, content) == 15); }; #[cfg(target_pointer_width = "32")] @@ -3167,8 +3167,8 @@ const _: () = { assert!(size_of::() == 1); assert!(align_of::() == 1); - assert!(size_of::() == 1); - assert!(align_of::() == 1); + assert!(size_of::() == 1); + assert!(align_of::() == 1); // Padding: 0 bytes assert!(size_of::() == 1); @@ -3182,7 +3182,7 @@ const _: () = { assert!(offset_of!(Comment, kind) == 12); assert!(offset_of!(Comment, position) == 13); assert!(offset_of!(Comment, newlines) == 14); - assert!(offset_of!(Comment, annotation) == 15); + assert!(offset_of!(Comment, content) == 15); }; #[cfg(not(any(target_pointer_width = "64", target_pointer_width = "32")))] diff --git a/crates/oxc_ast/src/generated/derive_clone_in.rs b/crates/oxc_ast/src/generated/derive_clone_in.rs index 20ea4bfab9e4c..6f1df9c5533a3 100644 --- a/crates/oxc_ast/src/generated/derive_clone_in.rs +++ b/crates/oxc_ast/src/generated/derive_clone_in.rs @@ -7852,8 +7852,8 @@ impl<'new_alloc> CloneIn<'new_alloc> for CommentPosition { } } -impl<'new_alloc> CloneIn<'new_alloc> for CommentAnnotation { - type Cloned = CommentAnnotation; +impl<'new_alloc> CloneIn<'new_alloc> for CommentContent { + type Cloned = CommentContent; #[inline(always)] fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned { @@ -7876,7 +7876,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for Comment { kind: CloneIn::clone_in(&self.kind, allocator), position: CloneIn::clone_in(&self.position, allocator), newlines: CloneIn::clone_in(&self.newlines, allocator), - annotation: CloneIn::clone_in(&self.annotation, allocator), + content: CloneIn::clone_in(&self.content, allocator), } } @@ -7887,7 +7887,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for Comment { kind: CloneIn::clone_in_with_semantic_ids(&self.kind, allocator), position: CloneIn::clone_in_with_semantic_ids(&self.position, allocator), newlines: CloneIn::clone_in_with_semantic_ids(&self.newlines, allocator), - annotation: CloneIn::clone_in_with_semantic_ids(&self.annotation, allocator), + content: CloneIn::clone_in_with_semantic_ids(&self.content, allocator), } } } diff --git a/crates/oxc_ast/src/generated/derive_content_eq.rs b/crates/oxc_ast/src/generated/derive_content_eq.rs index 4c5ecb96c4167..e93c0cc775b1c 100644 --- a/crates/oxc_ast/src/generated/derive_content_eq.rs +++ b/crates/oxc_ast/src/generated/derive_content_eq.rs @@ -2476,7 +2476,7 @@ impl ContentEq for CommentPosition { } } -impl ContentEq for CommentAnnotation { +impl ContentEq for CommentContent { fn content_eq(&self, other: &Self) -> bool { self == other } @@ -2488,6 +2488,6 @@ impl ContentEq for Comment { && ContentEq::content_eq(&self.kind, &other.kind) && ContentEq::content_eq(&self.position, &other.position) && ContentEq::content_eq(&self.newlines, &other.newlines) - && ContentEq::content_eq(&self.annotation, &other.annotation) + && ContentEq::content_eq(&self.content, &other.content) } } diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index b9880889f5faa..a038cec6a167c 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -73,7 +73,7 @@ mod generated { pub use generated::{ast_builder, ast_kind}; pub use crate::{ - ast::comment::{Comment, CommentAnnotation, CommentKind, CommentPosition}, + ast::comment::{Comment, CommentContent, CommentKind, CommentPosition}, ast_builder::AstBuilder, ast_builder_impl::NONE, ast_kind::{AstKind, AstType}, diff --git a/crates/oxc_codegen/src/comment.rs b/crates/oxc_codegen/src/comment.rs index 50a8a81245bff..746d60edc2a05 100644 --- a/crates/oxc_codegen/src/comment.rs +++ b/crates/oxc_codegen/src/comment.rs @@ -22,16 +22,14 @@ impl Codegen<'_> { continue; } let mut add = false; - if comment.is_legal() { - if self.options.print_legal_comment() { + if comment.is_leading() { + if comment.is_legal() && self.options.print_legal_comment() { add = true; } - } else if comment.is_leading() { - if comment.is_annotation() { - if self.options.print_annotation_comment() { - add = true; - } - } else if self.options.print_normal_comment() { + if comment.is_annotation() && self.options.print_annotation_comment() { + add = true; + } + if comment.is_normal() && self.options.print_normal_comment() { add = true; } } diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index 5c81b7b647d39..6850c66d329ad 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -739,7 +739,9 @@ impl Gen for FunctionBody<'_> { let span_end = self.span.end; let comments_at_end = if span_end > 0 { p.get_comments(span_end - 1) } else { None }; let single_line = if self.is_empty() { - comments_at_end.as_ref().is_none_or(|comments| comments.iter().all(|c| c.is_block())) + comments_at_end.as_ref().is_none_or(|comments| { + comments.iter().all(|c| !c.preceded_by_newline() && !c.followed_by_newline()) + }) } else { false }; diff --git a/crates/oxc_codegen/tests/integration/comments.rs b/crates/oxc_codegen/tests/integration/comments.rs index 5937db66feb3c..0f5c5d2d953c8 100644 --- a/crates/oxc_codegen/tests/integration/comments.rs +++ b/crates/oxc_codegen/tests/integration/comments.rs @@ -211,7 +211,8 @@ pub mod legal { #[test] fn legal_eof_comment() { - let options = CodegenOptions { legal_comments: LegalComment::Eof, ..Default::default() }; + let options = + CodegenOptions { legal_comments: LegalComment::Eof, ..CodegenOptions::default() }; snapshot_options("legal_eof_comments", &cases(), &options); } @@ -220,7 +221,7 @@ pub mod legal { let options = CodegenOptions { minify: true, legal_comments: LegalComment::Eof, - ..Default::default() + ..CodegenOptions::default() }; snapshot_options("legal_eof_minify_comments", &cases(), &options); } @@ -229,7 +230,7 @@ pub mod legal { fn legal_linked_comment() { let options = CodegenOptions { legal_comments: LegalComment::Linked(String::from("test.js")), - ..Default::default() + ..CodegenOptions::default() }; snapshot_options("legal_linked_comments", &cases(), &options); } @@ -237,7 +238,7 @@ pub mod legal { #[test] fn legal_external_comment() { let options = - CodegenOptions { legal_comments: LegalComment::External, ..Default::default() }; + CodegenOptions { legal_comments: LegalComment::External, ..CodegenOptions::default() }; let code = "/* @license */\n/* @preserve */\nfoo;\n"; let ret = codegen_options(code, &options); assert_eq!(ret.code, "foo;\n"); diff --git a/crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap b/crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap index ed88cc0a874b0..577fe341271e9 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/legal_eof_comments.snap @@ -99,10 +99,10 @@ function foo() { ---------- function foo() { (() => { - /** - * @preserve - */ -})(); + /** + * @preserve + */ + })(); /** * @preserve */ @@ -110,6 +110,10 @@ function foo() { /** * @preserve */ +/** + * @preserve +*/ + ########## 8 /** * @preserve @@ -119,3 +123,7 @@ function foo() { /** * @preserve */ + +/** +* @preserve +*/ diff --git a/crates/oxc_codegen/tests/integration/snapshots/legal_eof_minify_comments.snap b/crates/oxc_codegen/tests/integration/snapshots/legal_eof_minify_comments.snap index 924ff56abb977..3cd79a7c2497b 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/legal_eof_minify_comments.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/legal_eof_minify_comments.snap @@ -92,6 +92,10 @@ function foo(){(()=>{ /** * @preserve */ +/** +* @preserve +*/ + ########## 8 /** * @preserve @@ -101,3 +105,7 @@ function foo(){(()=>{ /** * @preserve */ + +/** +* @preserve +*/ diff --git a/crates/oxc_codegen/tests/integration/snapshots/legal_inline_comments.snap b/crates/oxc_codegen/tests/integration/snapshots/legal_inline_comments.snap index cf21f7bf039a7..5b0e6df19c524 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/legal_inline_comments.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/legal_inline_comments.snap @@ -92,10 +92,10 @@ function foo() { ---------- function foo() { (() => { - /** - * @preserve - */ -})(); + /** + * @preserve + */ + })(); /** * @preserve */ diff --git a/crates/oxc_codegen/tests/integration/snapshots/legal_linked_comments.snap b/crates/oxc_codegen/tests/integration/snapshots/legal_linked_comments.snap index 273152bb5a881..d5f0f6b6d48d5 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/legal_linked_comments.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/legal_linked_comments.snap @@ -85,10 +85,10 @@ function foo() { ---------- function foo() { (() => { - /** - * @preserve - */ -})(); + /** + * @preserve + */ + })(); /** * @preserve */ @@ -96,6 +96,7 @@ function foo() { /** * @preserve */ +/*! For license information please see test.js */ ########## 8 /** * @preserve @@ -105,3 +106,5 @@ function foo() { /** * @preserve */ + +/*! For license information please see test.js */ diff --git a/crates/oxc_parser/src/lexer/trivia_builder.rs b/crates/oxc_parser/src/lexer/trivia_builder.rs index 9c887490ad2fc..8773740aad6b4 100644 --- a/crates/oxc_parser/src/lexer/trivia_builder.rs +++ b/crates/oxc_parser/src/lexer/trivia_builder.rs @@ -1,5 +1,5 @@ use memchr::memchr_iter; -use oxc_ast::ast::{Comment, CommentAnnotation, CommentKind, CommentPosition}; +use oxc_ast::ast::{Comment, CommentContent, CommentKind, CommentPosition}; use oxc_span::Span; use super::{Kind, Token}; @@ -149,14 +149,18 @@ impl TriviaBuilder { let mut s = comment.content_span().source_text(source_text); if s.starts_with('!') { - comment.annotation = CommentAnnotation::Legal; + comment.content = CommentContent::Legal; return; } if comment.is_block() && s.starts_with('*') { // Ignore webpack comment `/*****/` if !s.bytes().all(|c| c == b'*') { - comment.annotation = CommentAnnotation::Jsdoc; + if contains_license_or_preserve_comment(s) { + comment.content = CommentContent::JsdocLegal; + } else { + comment.content = CommentContent::Jsdoc; + } return; } } @@ -165,38 +169,38 @@ impl TriviaBuilder { if let Some(ss) = s.strip_prefix('@') { if ss.starts_with("vite") { - comment.annotation = CommentAnnotation::Vite; + comment.content = CommentContent::Vite; return; } if ss.starts_with("license") || ss.starts_with("preserve") { - comment.annotation = CommentAnnotation::Legal; + comment.content = CommentContent::Legal; return; } s = ss; } else if let Some(ss) = s.strip_prefix('#') { s = ss; } else if s.starts_with("webpack") { - comment.annotation = CommentAnnotation::Webpack; + comment.content = CommentContent::Webpack; return; } else if ["v8 ignore", "c8 ignore", "node:coverage", "istanbul ignore"] .iter() .any(|ss| s.starts_with(ss)) { - comment.annotation = CommentAnnotation::CoverageIgnore; + comment.content = CommentContent::CoverageIgnore; } else { if contains_license_or_preserve_comment(s) { - comment.annotation = CommentAnnotation::Legal; + comment.content = CommentContent::Legal; } return; } let Some(s) = s.strip_prefix("__") else { return }; if s.starts_with("PURE__") { - comment.annotation = CommentAnnotation::Pure; + comment.content = CommentContent::Pure; self.has_pure_comment = true; } if s.starts_with("NO_SIDE_EFFECTS__") { - comment.annotation = CommentAnnotation::NoSideEffects; + comment.content = CommentContent::NoSideEffects; self.has_no_side_effects_comment = true; } } @@ -241,7 +245,7 @@ fn contains_license_or_preserve_comment(s: &str) -> bool { #[cfg(test)] mod test { use oxc_allocator::Allocator; - use oxc_ast::{Comment, CommentAnnotation, CommentKind, CommentPosition, ast::CommentNewlines}; + use oxc_ast::{Comment, CommentContent, CommentKind, CommentPosition, ast::CommentNewlines}; use oxc_span::{SourceType, Span}; use crate::Parser; @@ -269,7 +273,7 @@ mod test { position: CommentPosition::Leading, attached_to: 70, newlines: CommentNewlines::Leading | CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, Comment { span: Span::new(33, 45), @@ -277,7 +281,7 @@ mod test { position: CommentPosition::Leading, attached_to: 70, newlines: CommentNewlines::Leading | CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, Comment { span: Span::new(54, 69), @@ -285,7 +289,7 @@ mod test { position: CommentPosition::Leading, attached_to: 70, newlines: CommentNewlines::Leading, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, Comment { span: Span::new(76, 92), @@ -293,7 +297,7 @@ mod test { position: CommentPosition::Trailing, attached_to: 0, newlines: CommentNewlines::None, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, Comment { span: Span::new(93, 106), @@ -301,7 +305,7 @@ mod test { position: CommentPosition::Trailing, attached_to: 0, newlines: CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, Comment { span: Span::new(115, 138), @@ -309,7 +313,7 @@ mod test { position: CommentPosition::Leading, attached_to: 147, newlines: CommentNewlines::Leading | CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, ]; @@ -333,7 +337,7 @@ token /* Trailing 1 */ position: CommentPosition::Leading, attached_to: 36, newlines: CommentNewlines::Leading | CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, Comment { span: Span::new(42, 58), @@ -341,7 +345,7 @@ token /* Trailing 1 */ position: CommentPosition::Trailing, attached_to: 0, newlines: CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, ]; assert_eq!(comments, expected); @@ -366,7 +370,7 @@ token /* Trailing 1 */ position: CommentPosition::Leading, attached_to: 28, newlines: CommentNewlines::Leading | CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, Comment { span: Span::new(14, 26), @@ -374,7 +378,7 @@ token /* Trailing 1 */ position: CommentPosition::Leading, attached_to: 28, newlines: CommentNewlines::Leading | CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, ]; assert_eq!(comments, expected); @@ -397,7 +401,7 @@ token /* Trailing 1 */ position: CommentPosition::Leading, attached_to: 57, newlines: CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, Comment { span: Span::new(96, 116), @@ -405,7 +409,7 @@ token /* Trailing 1 */ position: CommentPosition::Leading, attached_to: 129, newlines: CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, ]; assert_eq!(comments, expected); @@ -427,7 +431,7 @@ token /* Trailing 1 */ position: CommentPosition::Leading, attached_to: 55, newlines: CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, Comment { span: Span::new(79, 99), @@ -435,7 +439,7 @@ token /* Trailing 1 */ position: CommentPosition::Leading, attached_to: 116, newlines: CommentNewlines::Trailing, - annotation: CommentAnnotation::None, + content: CommentContent::None, }, ]; assert_eq!(comments, expected); @@ -444,32 +448,34 @@ token /* Trailing 1 */ #[test] fn comment_parsing() { let data = [ - ("/*! legal */", CommentAnnotation::Legal), - ("/* @preserve */", CommentAnnotation::Legal), - ("/* @license */", CommentAnnotation::Legal), - ("/* foo @preserve */", CommentAnnotation::Legal), - ("/* foo @license */", CommentAnnotation::Legal), - ("/** jsdoc */", CommentAnnotation::Jsdoc), - ("/**/", CommentAnnotation::None), - ("/***/", CommentAnnotation::None), - ("/*@*/", CommentAnnotation::None), - ("/*@xreserve*/", CommentAnnotation::None), - ("/*@preserve*/", CommentAnnotation::Legal), - ("/*@voidzeroignoreme*/", CommentAnnotation::None), - ("/****/", CommentAnnotation::None), - ("/* @vite-ignore */", CommentAnnotation::Vite), - ("/* @vite-xxx */", CommentAnnotation::Vite), - ("/* webpackChunkName: 'my-chunk-name' */", CommentAnnotation::Webpack), - ("/* @__PURE__ */", CommentAnnotation::Pure), - ("/* @__NO_SIDE_EFFECTS__ */", CommentAnnotation::NoSideEffects), - ("/* #__PURE__ */", CommentAnnotation::Pure), - ("/* #__NO_SIDE_EFFECTS__ */", CommentAnnotation::NoSideEffects), + ("/*! legal */", CommentContent::Legal), + ("/* @preserve */", CommentContent::Legal), + ("/* @license */", CommentContent::Legal), + ("/* foo @preserve */", CommentContent::Legal), + ("/* foo @license */", CommentContent::Legal), + ("/** foo @preserve */", CommentContent::JsdocLegal), + ("/** foo @license */", CommentContent::JsdocLegal), + ("/** jsdoc */", CommentContent::Jsdoc), + ("/**/", CommentContent::None), + ("/***/", CommentContent::None), + ("/*@*/", CommentContent::None), + ("/*@xreserve*/", CommentContent::None), + ("/*@preserve*/", CommentContent::Legal), + ("/*@voidzeroignoreme*/", CommentContent::None), + ("/****/", CommentContent::None), + ("/* @vite-ignore */", CommentContent::Vite), + ("/* @vite-xxx */", CommentContent::Vite), + ("/* webpackChunkName: 'my-chunk-name' */", CommentContent::Webpack), + ("/* @__PURE__ */", CommentContent::Pure), + ("/* @__NO_SIDE_EFFECTS__ */", CommentContent::NoSideEffects), + ("/* #__PURE__ */", CommentContent::Pure), + ("/* #__NO_SIDE_EFFECTS__ */", CommentContent::NoSideEffects), ]; for (source_text, expected) in data { let comments = get_comments(source_text); assert_eq!(comments.len(), 1, "{source_text}"); - assert_eq!(comments[0].annotation, expected, "{source_text}"); + assert_eq!(comments[0].content, expected, "{source_text}"); } } }