doc_nested_refdefs: apply suggestions
Co-Authored-By: Jason Newcomb <jsnewcomb@pm.me>
This commit is contained in:
parent
44feca7f3f
commit
8dd45f18b3
1 changed files with 12 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue