diff --git a/unsupported/hermes/crates/hermes_comments/src/lib.rs b/unsupported/hermes/crates/hermes_comments/src/lib.rs index bd0a429716e..ccdd42db45a 100644 --- a/unsupported/hermes/crates/hermes_comments/src/lib.rs +++ b/unsupported/hermes/crates/hermes_comments/src/lib.rs @@ -13,10 +13,11 @@ use hermes_estree::SourceRange; use hermes_estree::Visitor; use hermes_parser::Comment; +pub type AttachedComments<'a> = Vec<(&'a str, SourceRange, Node<'a>, SourceRange)>; struct CommentAttachmentVisitor<'a> { comments: &'a [Comment], idx: usize, - attached_comments: Vec<(&'a str, SourceRange, Node<'a>, SourceRange)>, + attached_comments: AttachedComments<'a>, } impl<'a> Visitor<'a> for CommentAttachmentVisitor<'a> { @@ -51,7 +52,6 @@ impl<'a> Visitor<'a> for CommentAttachmentVisitor<'a> { node.as_node_enum(), node.range(), )); - return true; } false } @@ -66,7 +66,7 @@ impl<'a> CommentAttachmentVisitor<'a> { } } - fn result(self) -> Vec<(&'a str, SourceRange, Node<'a>, SourceRange)> { + fn result(self) -> AttachedComments<'a> { self.attached_comments } } @@ -76,7 +76,7 @@ impl<'a> CommentAttachmentVisitor<'a> { pub fn find_nodes_after_comments<'a>( program: &'a Program, comments: &'a [Comment], -) -> Vec<(&'a str, SourceRange, Node<'a>, SourceRange)> { +) -> AttachedComments<'a> { let mut comment_attachment_visitor = CommentAttachmentVisitor::new(comments); comment_attachment_visitor.visit_program(program); comment_attachment_visitor.result() diff --git a/unsupported/hermes/crates/hermes_estree/src/range.rs b/unsupported/hermes/crates/hermes_estree/src/range.rs index 503118ea7bd..123f03137dd 100644 --- a/unsupported/hermes/crates/hermes_estree/src/range.rs +++ b/unsupported/hermes/crates/hermes_estree/src/range.rs @@ -9,7 +9,7 @@ use serde::ser::SerializeTuple; use serde::Deserialize; use serde::Serialize; -#[derive(Deserialize, Copy, Clone, Debug, PartialEq, PartialOrd, Hash)] +#[derive(Deserialize, Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] pub struct SourceRange { pub start: u32, pub end: u32,