diff --git a/regex-lite/src/hir/parse.rs b/regex-lite/src/hir/parse.rs index 6d4009d8d..1983a9b89 100644 --- a/regex-lite/src/hir/parse.rs +++ b/regex-lite/src/hir/parse.rs @@ -593,8 +593,7 @@ impl<'a> Parser<'a> { 'u' => 4, 'U' => 8, unk => unreachable!( - "invalid start of fixed length hexadecimal number {}", - unk + "invalid start of fixed length hexadecimal number {unk}" ), }; if !self.bump_and_bump_space() { @@ -720,7 +719,7 @@ impl<'a> Parser<'a> { '?' => (0, Some(1)), '*' => (0, None), '+' => (1, None), - unk => unreachable!("unrecognized repetition operator '{}'", unk), + unk => unreachable!("unrecognized repetition operator '{unk}'"), }; let mut greedy = true; if self.bump() && self.char() == '?' { @@ -1216,7 +1215,7 @@ impl<'a> Parser<'a> { 'd' | 'D' => posix_class("digit").unwrap(), 's' | 'S' => posix_class("space").unwrap(), 'w' | 'W' => posix_class("word").unwrap(), - unk => unreachable!("invalid Perl class \\{}", unk), + unk => unreachable!("invalid Perl class \\{unk}"), }); if ch.is_ascii_uppercase() { class.negate(); diff --git a/regex-lite/src/nfa.rs b/regex-lite/src/nfa.rs index 8f37a5451..94b000ce8 100644 --- a/regex-lite/src/nfa.rs +++ b/regex-lite/src/nfa.rs @@ -136,7 +136,7 @@ impl core::fmt::Debug for NFA { writeln!(f, "NFA(")?; writeln!(f, "pattern: {}", self.pattern)?; for (sid, state) in self.states.iter().enumerate() { - writeln!(f, "{:07?}: {:?}", sid, state)?; + writeln!(f, "{sid:07?}: {state:?}")?; } writeln!(f, ")")?; Ok(()) @@ -206,14 +206,14 @@ impl core::fmt::Debug for State { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match *self { State::Char { target, ch } => { - write!(f, "{:?} => {:?}", ch, target) + write!(f, "{ch:?} => {target:?}") } State::Ranges { target, ref ranges } => { for (i, &(start, end)) in ranges.iter().enumerate() { if i > 0 { write!(f, ", ")?; } - write!(f, "{:?}-{:?} => {:?}", start, end, target)?; + write!(f, "{start:?}-{end:?} => {target:?}")?; } Ok(()) } @@ -225,18 +225,18 @@ impl core::fmt::Debug for State { if i > 0 { write!(f, ", ")?; } - write!(f, "{:?}", sid)?; + write!(f, "{sid:?}")?; } write!(f, ")") } State::Goto { target, look: None } => { - write!(f, "goto({:?})", target) + write!(f, "goto({target:?})") } State::Goto { target, look: Some(look) } => { - write!(f, "{:?} => {:?}", look, target) + write!(f, "{look:?} => {target:?}") } State::Capture { target, slot } => { - write!(f, "capture(slot={:?}) => {:?}", slot, target,) + write!(f, "capture(slot={slot:?}) => {target:?}") } State::Fail => write!(f, "FAIL"), State::Match => { diff --git a/regex-lite/src/string.rs b/regex-lite/src/string.rs index 4dba085f2..5de5d868c 100644 --- a/regex-lite/src/string.rs +++ b/regex-lite/src/string.rs @@ -1798,7 +1798,7 @@ impl<'h> Captures<'h> { .nfa() .static_explicit_captures_len() .expect("number of capture groups can vary in a match"); - assert_eq!(N, len, "asked for {} groups, but must ask for {}", N, len); + assert_eq!(N, len, "asked for {N} groups, but must ask for {len}"); let mut matched = self.iter().flatten(); let whole_match = matched.next().expect("a match").as_str(); let group_matches = [0; N].map(|_| { @@ -1965,7 +1965,7 @@ impl<'h> core::fmt::Debug for Captures<'h> { fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { write!(f, "{}", self.0)?; if let Some(name) = self.1 { - write!(f, "/{:?}", name)?; + write!(f, "/{name:?}")?; } Ok(()) } @@ -2013,7 +2013,7 @@ impl<'h> core::ops::Index for Captures<'h> { fn index(&self, i: usize) -> &str { self.get(i) .map(|m| m.as_str()) - .unwrap_or_else(|| panic!("no group at index '{}'", i)) + .unwrap_or_else(|| panic!("no group at index '{i}'")) } } @@ -2039,7 +2039,7 @@ impl<'h, 'n> core::ops::Index<&'n str> for Captures<'h> { fn index<'a>(&'a self, name: &'n str) -> &'a str { self.name(name) .map(|m| m.as_str()) - .unwrap_or_else(|| panic!("no group named '{}'", name)) + .unwrap_or_else(|| panic!("no group named '{name}'")) } } diff --git a/regex-lite/tests/string.rs b/regex-lite/tests/string.rs index 283e103a2..d47330ed3 100644 --- a/regex-lite/tests/string.rs +++ b/regex-lite/tests/string.rs @@ -23,8 +23,7 @@ fn run_test(re: &Regex, test: &RegexTest) -> TestResult { Ok(hay) => hay, Err(err) => { return TestResult::fail(&format!( - "haystack is not valid UTF-8: {}", - err + "haystack is not valid UTF-8: {err}", )); } }; @@ -45,7 +44,7 @@ fn run_test(re: &Regex, test: &RegexTest) -> TestResult { .map(|caps| testify_captures(&caps)); TestResult::captures(it) } - name => TestResult::fail(&format!("unrecognized test name: {}", name)), + name => TestResult::fail(&format!("unrecognized test name: {name}")), } } diff --git a/regex-test/lib.rs b/regex-test/lib.rs index 6cebbfae9..e6c1037e6 100644 --- a/regex-test/lib.rs +++ b/regex-test/lib.rs @@ -151,17 +151,17 @@ impl RegexTests { /// The given group name is assigned to all loaded tests. pub fn load_slice(&mut self, group_name: &str, data: &[u8]) -> Result<()> { let data = std::str::from_utf8(&data).with_context(|| { - format!("data in {} is not valid UTF-8", group_name) + format!("data in {group_name} is not valid UTF-8") })?; let mut index = 1; let mut tests: RegexTests = toml::from_str(&data).with_context(|| { - format!("error decoding TOML for '{}'", group_name) + format!("error decoding TOML for '{group_name}'") })?; for t in &mut tests.tests { t.group = group_name.to_string(); if t.name.is_empty() { - t.name = format!("{}", index); + t.name = format!("{index}"); index += 1; } t.full_name = format!("{}/{}", t.group, t.name); @@ -1101,7 +1101,7 @@ impl RegexTestFailureKind { let mut buf = String::new(); match *self { RegexTestFailureKind::UserFailure { ref why } => { - write!(buf, "failed by implementor because: {}", why)?; + write!(buf, "failed by implementor because: {why}")?; } RegexTestFailureKind::IsMatch => { if test.is_match() { @@ -1140,13 +1140,13 @@ impl RegexTestFailureKind { write!(buf, "expected regex to NOT compile, but it did")?; } RegexTestFailureKind::CompileError { ref err } => { - write!(buf, "expected regex to compile, failed: {}", err)?; + write!(buf, "expected regex to compile, failed: {err}")?; } RegexTestFailureKind::UnexpectedPanicCompile(ref msg) => { - write!(buf, "got unexpected panic while compiling:\n{}", msg)?; + write!(buf, "got unexpected panic while compiling:\n{msg}")?; } RegexTestFailureKind::UnexpectedPanicSearch(ref msg) => { - write!(buf, "got unexpected panic while searching:\n{}", msg)?; + write!(buf, "got unexpected panic while searching:\n{msg}")?; } } Ok(buf) diff --git a/src/error.rs b/src/error.rs index 0f222c537..9e90d5674 100644 --- a/src/error.rs +++ b/src/error.rs @@ -71,7 +71,7 @@ impl core::fmt::Display for Error { Error::Syntax(ref err) => err.fmt(f), Error::CompiledTooBig(limit) => write!( f, - "Compiled regex exceeds size limit of {limit} bytes." + "Compiled regex exceeds size limit of {limit} bytes.", ), } } diff --git a/src/regex/bytes.rs b/src/regex/bytes.rs index 11b285515..c5a8a920d 100644 --- a/src/regex/bytes.rs +++ b/src/regex/bytes.rs @@ -1992,7 +1992,7 @@ impl<'h> core::ops::Index for Captures<'h> { fn index<'a>(&'a self, i: usize) -> &'a [u8] { self.get(i) .map(|m| m.as_bytes()) - .unwrap_or_else(|| panic!("no group at index '{}'", i)) + .unwrap_or_else(|| panic!("no group at index '{i}'")) } } @@ -2018,7 +2018,7 @@ impl<'h, 'n> core::ops::Index<&'n str> for Captures<'h> { fn index<'a>(&'a self, name: &'n str) -> &'a [u8] { self.name(name) .map(|m| m.as_bytes()) - .unwrap_or_else(|| panic!("no group named '{}'", name)) + .unwrap_or_else(|| panic!("no group named '{name}'")) } } diff --git a/src/regex/string.rs b/src/regex/string.rs index 8363cbb79..9d3d823d2 100644 --- a/src/regex/string.rs +++ b/src/regex/string.rs @@ -2000,7 +2000,7 @@ impl<'h> core::ops::Index for Captures<'h> { fn index<'a>(&'a self, i: usize) -> &'a str { self.get(i) .map(|m| m.as_str()) - .unwrap_or_else(|| panic!("no group at index '{}'", i)) + .unwrap_or_else(|| panic!("no group at index '{i}'")) } } @@ -2026,7 +2026,7 @@ impl<'h, 'n> core::ops::Index<&'n str> for Captures<'h> { fn index<'a>(&'a self, name: &'n str) -> &'a str { self.name(name) .map(|m| m.as_str()) - .unwrap_or_else(|| panic!("no group named '{}'", name)) + .unwrap_or_else(|| panic!("no group named '{name}'")) } } diff --git a/tests/suite_string.rs b/tests/suite_string.rs index c8fb3d08a..2a6d7709b 100644 --- a/tests/suite_string.rs +++ b/tests/suite_string.rs @@ -23,7 +23,7 @@ fn run_test(re: &Regex, test: &RegexTest) -> TestResult { Ok(hay) => hay, Err(err) => { return TestResult::fail(&format!( - "haystack is not valid UTF-8: {err}" + "haystack is not valid UTF-8: {err}", )); } }; diff --git a/tests/suite_string_set.rs b/tests/suite_string_set.rs index 49b87ec45..122e39c75 100644 --- a/tests/suite_string_set.rs +++ b/tests/suite_string_set.rs @@ -21,7 +21,7 @@ fn run_test(re: &RegexSet, test: &RegexTest) -> TestResult { Ok(hay) => hay, Err(err) => { return TestResult::fail(&format!( - "haystack is not valid UTF-8: {err}" + "haystack is not valid UTF-8: {err}", )); } };