Skip to content

Commit

Permalink
doc_nested_refdefs: apply suggestions
Browse files Browse the repository at this point in the history
Co-Authored-By: Jason Newcomb <[email protected]>
  • Loading branch information
notriddle and Jarcho committed Nov 27, 2024
1 parent 44feca7 commit 8dd45f1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions clippy_lints/src/doc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,23 +1120,23 @@ impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> {
}
}

#[allow(clippy::range_plus_one)] // inclusive ranges aren't the same type
#[expect(clippy::range_plus_one)] // inclusive ranges aren't the same type
fn looks_like_refdef(doc: &str, range: Range<usize>) -> Option<Range<usize>> {
let offset = range.start;
let mut iterator = doc.as_bytes()[range].iter().copied().enumerate();
let mut start = None;
while let Some((i, byte)) = iterator.next() {
if byte == b'\\' {
iterator.next();
continue;
}
if byte == b'[' {
start = Some(i + offset);
}
if let Some(start) = start
&& byte == b']'
{
return Some(start..i + offset + 1);
match byte {
b'\\' => {
iterator.next();
},
b'[' => {
start = Some(i + offset);
},
b']' if let Some(start) = start => {
return Some(start..i + offset + 1);
},
_ => {},
}
}
None
Expand Down

0 comments on commit 8dd45f1

Please sign in to comment.