Skip to main content

Module comments

Module comments 

Source
Expand description

comments command: list every comment span in a set of files, apply a hash-guarded batch of delete/replace edits to them, and verify that code is unchanged once comments are ignored.

syn drops // and /* */ comments and turns /// / //! into #[doc] attributes, so it cannot answer “where are the comments”. This module runs a small lexer over the raw source that understands strings, raw strings, char literals vs lifetimes and nested block comments, and uses syn only for the questions syn is good at: which item a comment is attached to, whether it sits inside a fn body, and whether two files are the same code.

Every apply is gated by the same verify check before anything is written, and records a whole-file backup under one run_id so rs-hack revert <run_id> undoes the batch.

Structs§

ApplyArgs
ApplyReport
AttachedItem
CommentOp
One op in an apply batch, resolved by hash alone – pre-1.0, there is no span field and no fallback.
CommentSpan
Difference
FileVerdict
ListArgs
ListReport
OpOutcome
VerifyReport

Enums§

CommentKind
OpKind
VerifyArgs

Constants§

ANNOTATION_MARKERS
Annotation markers the board indexes; a span holding one is refused by apply unless the caller opts in, and flagged by list so callers can exclude it.
FILE_BACKUP_NODE_TYPE
Node type recorded on the whole-file backup an apply run saves; restore_from_nodes writes original_content straight back for it.

Functions§

apply
compare_sources
Compare two sources as code. Ok(None) means equal modulo comments, whitespace and doc attributes; Ok(Some(d)) names the first item that differs.
list
parse_batch
parse_line_range
Parse a --lines A-B argument: 1-indexed, inclusive, A <= B.
render_apply
render_list
render_verify
to_batch
The comments list --format batch payload: one ready-made "keep" op stub per non-annotation span in report.
verify