Skip to content

Commit a285b58

Browse files
committed
Add some comments for magic numbers + Add tests
1 parent d642c3b commit a285b58

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clippy_lints/src/doc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span:
264264
let mut doc = doc.to_owned();
265265
doc.push('\n');
266266
let len = doc.len();
267+
// +3 skips the opening delimiter
267268
return (doc, vec![(len, span.with_lo(span.lo() + BytePos(3)))]);
268269
}
269270

@@ -273,7 +274,7 @@ pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span:
273274
let offset = line.as_ptr() as usize - doc.as_ptr() as usize;
274275
debug_assert_eq!(offset as u32 as usize, offset);
275276
contains_initial_stars |= line.trim_start().starts_with('*');
276-
// +1 for the newline
277+
// +1 adds the newline, +3 skips the opening delimiter
277278
sizes.push((line.len() + 1, span.with_lo(span.lo() + BytePos(3 + offset as u32))));
278279
}
279280
if !contains_initial_stars {

clippy_lints/src/tabs_in_doc_comments.rs

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ impl TabsInDocComments {
6464
let comment = comment.as_str();
6565

6666
for (lo, hi) in get_chunks_of_tabs(&comment) {
67+
// +3 skips the opening delimiter
6768
let new_span = Span::new(
6869
attr.span.lo() + BytePos(3 + lo),
6970
attr.span.lo() + BytePos(3 + hi),

0 commit comments

Comments
 (0)