Skip to content

Commit

Permalink
Fix some clipplies
Browse files Browse the repository at this point in the history
  • Loading branch information
ridiculousfish committed Jan 12, 2025
1 parent ff467d2 commit d861b38
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl<'m> Groups<'m> {
}
}

impl<'m> Iterator for Groups<'m> {
impl Iterator for Groups<'_> {
type Item = Option<Range>;

#[inline]
Expand Down
8 changes: 4 additions & 4 deletions src/classicalbacktrack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,10 @@ impl<'a, Input: InputIndexer> MatchAttempter<'a, Input> {
// Copy the positions since these destructively move them.
let prev_wordchar = input
.peek_left(pos)
.map_or(false, Input::CharProps::is_word_char);
.is_some_and(Input::CharProps::is_word_char);
let curr_wordchar = input
.peek_right(pos)
.map_or(false, Input::CharProps::is_word_char);
.is_some_and(Input::CharProps::is_word_char);
let is_boundary = prev_wordchar != curr_wordchar;
next_or_bt!(is_boundary != invert)
}
Expand Down Expand Up @@ -908,7 +908,7 @@ impl<'r, Input: InputIndexer> BacktrackExecutor<'r, Input> {
}
}

impl<'r, Input: InputIndexer> BacktrackExecutor<'r, Input> {
impl<Input: InputIndexer> BacktrackExecutor<'_, Input> {
fn successful_match(&mut self, start: Input::Position, end: Input::Position) -> Match {
// We want to simultaneously map our groups to offsets, and clear the groups.
// A for loop is the easiest way to do this while satisfying the borrow checker.
Expand Down Expand Up @@ -964,7 +964,7 @@ impl<'r, Input: InputIndexer> BacktrackExecutor<'r, Input> {
}
}

impl<'a, Input: InputIndexer> exec::MatchProducer for BacktrackExecutor<'a, Input> {
impl<Input: InputIndexer> exec::MatchProducer for BacktrackExecutor<'_, Input> {
type Position = Input::Position;

fn initial_position(&self, offset: usize) -> Option<Self::Position> {
Expand Down
2 changes: 1 addition & 1 deletion src/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<'a> Utf8Input<'a> {

#[inline(always)]
fn bytelength(&self) -> usize {
self.input.as_bytes().len()
self.input.len()
}

#[inline(always)]
Expand Down
4 changes: 2 additions & 2 deletions src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ where
walk: Walk,
}

impl<'a, F> Walker<'a, F>
impl<F> Walker<'_, F>
where
F: FnMut(&Node, &mut Walk),
{
Expand Down Expand Up @@ -348,7 +348,7 @@ where
walk: Walk,
}

impl<'a, F> MutWalker<'a, F>
impl<F> MutWalker<'_, F>
where
F: FnMut(&mut Node, &mut Walk),
{
Expand Down
6 changes: 3 additions & 3 deletions src/pikevm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ fn try_match_state<Input: InputIndexer, Dir: Direction>(
&Insn::WordBoundary { invert } => {
let prev_wordchar = input
.peek_left(s.pos)
.map_or(false, Input::CharProps::is_word_char);
.is_some_and(Input::CharProps::is_word_char);
let curr_wordchar = input
.peek_right(s.pos)
.map_or(false, Input::CharProps::is_word_char);
.is_some_and(Input::CharProps::is_word_char);
let is_boundary = prev_wordchar != curr_wordchar;
nextinsn_or_fail!(is_boundary != invert)
}
Expand Down Expand Up @@ -408,7 +408,7 @@ impl<'r, 't> exec::Executor<'r, 't> for PikeVMExecutor<'r, AsciiInput<'t>> {
}
}

impl<'a, Input: InputIndexer> exec::MatchProducer for PikeVMExecutor<'a, Input> {
impl<Input: InputIndexer> exec::MatchProducer for PikeVMExecutor<'_, Input> {
type Position = Input::Position;

fn initial_position(&self, offset: usize) -> Option<Self::Position> {
Expand Down
2 changes: 1 addition & 1 deletion src/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub type DefPosition<'a> = RefPosition<'a>;
pub struct IndexPosition<'a>(usize, PhantomData<&'a ()>);

#[allow(dead_code)]
impl<'a> IndexPosition<'a> {
impl IndexPosition<'_> {
/// IndexPosition does not enforce its size.
#[inline(always)]
pub fn check_size() {}
Expand Down
16 changes: 8 additions & 8 deletions src/scm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct CharSet<'a> {
pub chars: &'a [u32; MAX_CHAR_SET_LENGTH],
}

impl<'a, Input: InputIndexer, Dir: Direction> SingleCharMatcher<Input, Dir> for CharSet<'a> {
impl<Input: InputIndexer, Dir: Direction> SingleCharMatcher<Input, Dir> for CharSet<'_> {
#[inline(always)]
fn matches(&self, input: &Input, dir: Dir, pos: &mut Input::Position) -> bool {
match cursor::next(input, dir, pos) {
Expand All @@ -61,7 +61,7 @@ pub struct Bracket<'a> {
pub bc: &'a BracketContents,
}

impl<'a, Input: InputIndexer, Dir: Direction> SingleCharMatcher<Input, Dir> for Bracket<'a> {
impl<Input: InputIndexer, Dir: Direction> SingleCharMatcher<Input, Dir> for Bracket<'_> {
#[inline(always)]
fn matches(&self, input: &Input, dir: Dir, pos: &mut Input::Position) -> bool {
match cursor::next(input, dir, pos) {
Expand Down Expand Up @@ -110,19 +110,19 @@ pub struct MatchByteSet<'a, Bytes: ByteSet> {
pub bytes: &'a Bytes,
}

impl<'a, Input: InputIndexer, Dir: Direction, Bytes: ByteSet> SingleCharMatcher<Input, Dir>
for MatchByteSet<'a, Bytes>
impl<Input: InputIndexer, Dir: Direction, Bytes: ByteSet> SingleCharMatcher<Input, Dir>
for MatchByteSet<'_, Bytes>
{
#[inline(always)]
fn matches(&self, input: &Input, dir: Dir, pos: &mut Input::Position) -> bool {
if Input::CODE_UNITS_ARE_BYTES {
// Code units are bytes so we can skip decoding the full element.
cursor::next_byte(input, dir, pos).map_or(false, |b| self.bytes.contains(b))
cursor::next_byte(input, dir, pos).is_some_and(|b| self.bytes.contains(b))
} else {
// Must decode the full element.
cursor::next(input, dir, pos)
.and_then(|c| c.as_u32().try_into().ok())
.map_or(false, |c| self.bytes.contains(c))
.is_some_and(|c| self.bytes.contains(c))
}
}
}
Expand Down Expand Up @@ -151,8 +151,8 @@ pub struct MatchByteSeq<'a, Bytes: ByteSeq> {
pub bytes: &'a Bytes,
}

impl<'a, Input: InputIndexer, Dir: Direction, Bytes: ByteSeq> SingleCharMatcher<Input, Dir>
for MatchByteSeq<'a, Bytes>
impl<Input: InputIndexer, Dir: Direction, Bytes: ByteSeq> SingleCharMatcher<Input, Dir>
for MatchByteSeq<'_, Bytes>
{
#[inline(always)]
fn matches(&self, input: &Input, dir: Dir, pos: &mut Input::Position) -> bool {
Expand Down
3 changes: 1 addition & 2 deletions src/startpredicate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Support for quickly finding potential match locations.
use crate::bytesearch::ByteBitmap;
use crate::codepointset;
use crate::insn::StartPredicate;
Expand All @@ -8,8 +9,6 @@ use crate::util::{add_utf8_first_bytes_to_bitmap, utf8_first_byte};
use alloc::{boxed::Box, vec::Vec};
use core::convert::TryInto;

/// Support for quickly finding potential match locations.
/// Convert the code point set to a first-byte bitmap.
/// That is, make a list of all of the possible first bytes of every contained
/// code point, and store that in a bitmap.
Expand Down
4 changes: 2 additions & 2 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ impl TestCompiledRegex {
#[track_caller]
pub fn find_utf16(&self, input: &str) -> Option<regress::Match> {
let input = input.encode_utf16().collect::<Vec<_>>();
self.re.find_from_utf16(&input, 0).into_iter().next()
self.re.find_from_utf16(&input, 0).next()
}

/// Encode a string as UTF16, and match against it as UCS2.
#[cfg(feature = "utf16")]
#[track_caller]
pub fn find_ucs2(&self, input: &str) -> Option<regress::Match> {
let input = input.encode_utf16().collect::<Vec<_>>();
self.re.find_from_ucs2(&input, 0).into_iter().next()
self.re.find_from_ucs2(&input, 0).next()
}

/// Match against a string, returning the first formatted match.
Expand Down
12 changes: 6 additions & 6 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1835,10 +1835,10 @@ mod utf16_tests {
let input = "赔"; // U+8D54

let re = tc.compile(r"[A-Z]"); // 0x41 - 0x5A
let matched = re.find_utf16(&input);
let matched = re.find_utf16(input);
assert!(matched.is_none());

let matched = re.find_ucs2(&input);
let matched = re.find_ucs2(input);
assert!(matched.is_none());
}

Expand All @@ -1853,20 +1853,20 @@ mod utf16_tests {
let re = tc.compile(r"abc");

let input = "abc";
let matched = re.find_utf16(&input);
let matched = re.find_utf16(input);
assert!(matched.is_some());
assert_eq!(matched.unwrap().range, 0..3);

let matched = re.find_ucs2(&input);
let matched = re.find_ucs2(input);
assert!(matched.is_some());
assert_eq!(matched.unwrap().range, 0..3);

let input = "xxxabczzz";
let matched = re.find_utf16(&input);
let matched = re.find_utf16(input);
assert!(matched.is_some());
assert_eq!(matched.unwrap().range, 3..6);

let matched = re.find_ucs2(&input);
let matched = re.find_ucs2(input);
assert!(matched.is_some());
assert_eq!(matched.unwrap().range, 3..6);
}
Expand Down
12 changes: 6 additions & 6 deletions tests/unicode_property_escapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4505,7 +4505,7 @@ fn unicode_escape_property_binary_alphabetic() {
}

fn unicode_escape_property_binary_alphabetic_tc(tc: TestConfig) {
const CODE_POINTS: [&str; 1141] = [
static CODE_POINTS: [&str; 1141] = [
"\u{41}",
"\u{61}",
"\u{aa}",
Expand Down Expand Up @@ -9106,7 +9106,7 @@ fn unicode_escape_property_binary_graphemebase() {
}

fn unicode_escape_property_binary_graphemebase_tc(tc: TestConfig) {
const CODE_POINTS: [&str; 1743] = [
static CODE_POINTS: [&str; 1743] = [
"\u{20}",
"\u{21}",
"\u{24}",
Expand Down Expand Up @@ -11259,7 +11259,7 @@ fn unicode_escape_property_binary_idcontinue() {
}

fn unicode_escape_property_binary_idcontinue_tc(tc: TestConfig) {
const CODE_POINTS: [&str; 1344] = [
static CODE_POINTS: [&str; 1344] = [
"\u{30}",
"\u{41}",
"\u{5f}",
Expand Down Expand Up @@ -13634,7 +13634,7 @@ fn unicode_escape_property_binary_xidcontinue() {
}

fn unicode_escape_property_binary_xidcontinue_tc(tc: TestConfig) {
const CODE_POINTS: [&str; 1348] = [
static CODE_POINTS: [&str; 1348] = [
"\u{30}",
"\u{41}",
"\u{5f}",
Expand Down Expand Up @@ -25301,7 +25301,7 @@ fn unicode_escape_property_gc_casedletter() {
}

fn unicode_escape_property_gc_casedletter_tc(tc: TestConfig) {
const CODE_POINTS: [&str; 1314] = [
static CODE_POINTS: [&str; 1314] = [
"\u{61}",
"\u{b5}",
"\u{df}",
Expand Down Expand Up @@ -27396,7 +27396,7 @@ fn unicode_escape_property_gc_letter() {
}

fn unicode_escape_property_gc_letter_tc(tc: TestConfig) {
const CODE_POINTS: [&str; 1896] = [
static CODE_POINTS: [&str; 1896] = [
"\u{61}",
"\u{b5}",
"\u{df}",
Expand Down

0 comments on commit d861b38

Please sign in to comment.