Skip to content

Commit

Permalink
Add some comments for magic numbers + Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Aug 6, 2020
1 parent d642c3b commit a285b58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clippy_lints/src/doc.rs
Expand Up @@ -264,6 +264,7 @@ pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span:
let mut doc = doc.to_owned();
doc.push('\n');
let len = doc.len();
// +3 skips the opening delimiter
return (doc, vec![(len, span.with_lo(span.lo() + BytePos(3)))]);
}

Expand All @@ -273,7 +274,7 @@ pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span:
let offset = line.as_ptr() as usize - doc.as_ptr() as usize;
debug_assert_eq!(offset as u32 as usize, offset);
contains_initial_stars |= line.trim_start().starts_with('*');
// +1 for the newline
// +1 adds the newline, +3 skips the opening delimiter
sizes.push((line.len() + 1, span.with_lo(span.lo() + BytePos(3 + offset as u32))));
}
if !contains_initial_stars {
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/tabs_in_doc_comments.rs
Expand Up @@ -64,6 +64,7 @@ impl TabsInDocComments {
let comment = comment.as_str();

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

0 comments on commit a285b58

Please sign in to comment.