Skip to content

Commit 19172cc

Browse files
authored
style: inline formatting arguments
PR #1286
1 parent 2695e29 commit 19172cc

File tree

31 files changed

+149
-183
lines changed

31 files changed

+149
-183
lines changed

regex-automata/src/dfa/accel.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub(crate) fn find_fwd(
102102
2 => memchr::memchr2(bs[0], bs[1], &haystack[at..])?,
103103
3 => memchr::memchr3(bs[0], bs[1], bs[2], &haystack[at..])?,
104104
0 => panic!("cannot find with empty needles"),
105-
n => panic!("invalid needles length: {}", n),
105+
n => panic!("invalid needles length: {n}"),
106106
};
107107
Some(at + i)
108108
}
@@ -122,7 +122,7 @@ pub(crate) fn find_rev(
122122
2 => memchr::memrchr2(bs[0], bs[1], &haystack[..at]),
123123
3 => memchr::memrchr3(bs[0], bs[1], bs[2], &haystack[..at]),
124124
0 => panic!("cannot find with empty needles"),
125-
n => panic!("invalid needles length: {}", n),
125+
n => panic!("invalid needles length: {n}"),
126126
}
127127
}
128128

@@ -267,7 +267,7 @@ impl<A: AsRef<[AccelTy]>> Accels<A> {
267267
#[cfg_attr(feature = "perf-inline", inline(always))]
268268
pub fn needles(&self, i: usize) -> &[u8] {
269269
if i >= self.len() {
270-
panic!("invalid accelerator index {}", i);
270+
panic!("invalid accelerator index {i}");
271271
}
272272
let bytes = self.as_bytes();
273273
let offset = ACCEL_TY_SIZE + i * ACCEL_CAP;
@@ -313,8 +313,8 @@ impl<A: AsRef<[AccelTy]>> Accels<A> {
313313
assert_eq!(
314314
nwrite % ACCEL_TY_SIZE,
315315
0,
316-
"expected accelerator bytes written to be a multiple of {}",
317-
ACCEL_TY_SIZE,
316+
"expected accelerator bytes written to be a multiple \
317+
of {ACCEL_TY_SIZE}",
318318
);
319319
if dst.len() < nwrite {
320320
return Err(SerializeError::buffer_too_small("accelerators"));

regex-automata/src/dfa/dense.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2837,8 +2837,8 @@ impl OwnedDFA {
28372837
}
28382838
assert!(
28392839
!matches.contains_key(&start_id),
2840-
"{:?} is both a start and a match state, which is not allowed",
2841-
start_id,
2840+
"{start_id:?} is both a start and a match state, \
2841+
which is not allowed",
28422842
);
28432843
is_start.insert(start_id);
28442844
}
@@ -3098,7 +3098,7 @@ impl<T: AsRef<[u32]>> fmt::Debug for DFA<T> {
30983098
} else {
30993099
self.to_index(state.id())
31003100
};
3101-
write!(f, "{:06?}: ", id)?;
3101+
write!(f, "{id:06?}: ")?;
31023102
state.fmt(f)?;
31033103
write!(f, "\n")?;
31043104
}
@@ -3114,11 +3114,11 @@ impl<T: AsRef<[u32]>> fmt::Debug for DFA<T> {
31143114
Anchored::No => writeln!(f, "START-GROUP(unanchored)")?,
31153115
Anchored::Yes => writeln!(f, "START-GROUP(anchored)")?,
31163116
Anchored::Pattern(pid) => {
3117-
writeln!(f, "START_GROUP(pattern: {:?})", pid)?
3117+
writeln!(f, "START_GROUP(pattern: {pid:?})")?
31183118
}
31193119
}
31203120
}
3121-
writeln!(f, " {:?} => {:06?}", sty, id)?;
3121+
writeln!(f, " {sty:?} => {id:06?}")?;
31223122
}
31233123
if self.pattern_len() > 1 {
31243124
writeln!(f, "")?;
@@ -3129,13 +3129,13 @@ impl<T: AsRef<[u32]>> fmt::Debug for DFA<T> {
31293129
} else {
31303130
self.to_index(id)
31313131
};
3132-
write!(f, "MATCH({:06?}): ", id)?;
3132+
write!(f, "MATCH({id:06?}): ")?;
31333133
for (i, &pid) in self.ms.pattern_id_slice(i).iter().enumerate()
31343134
{
31353135
if i > 0 {
31363136
write!(f, ", ")?;
31373137
}
3138-
write!(f, "{:?}", pid)?;
3138+
write!(f, "{pid:?}")?;
31393139
}
31403140
writeln!(f, "")?;
31413141
}
@@ -3525,8 +3525,8 @@ impl TransitionTable<Vec<u32>> {
35253525
///
35263526
/// Both id1 and id2 must point to valid states, otherwise this panics.
35273527
fn swap(&mut self, id1: StateID, id2: StateID) {
3528-
assert!(self.is_valid(id1), "invalid 'id1' state: {:?}", id1);
3529-
assert!(self.is_valid(id2), "invalid 'id2' state: {:?}", id2);
3528+
assert!(self.is_valid(id1), "invalid 'id1' state: {id1:?}");
3529+
assert!(self.is_valid(id2), "invalid 'id2' state: {id2:?}");
35303530
// We only need to swap the parts of the state that are used. So if the
35313531
// stride is 64, but the alphabet length is only 33, then we save a lot
35323532
// of work.
@@ -4277,7 +4277,7 @@ impl<T: AsMut<[u32]>> StartTable<T> {
42774277
let len = self
42784278
.pattern_len
42794279
.expect("start states for each pattern enabled");
4280-
assert!(pid < len, "invalid pattern ID {:?}", pid);
4280+
assert!(pid < len, "invalid pattern ID {pid:?}");
42814281
self.stride
42824282
.checked_mul(pid)
42834283
.unwrap()
@@ -4868,9 +4868,9 @@ impl<'a> fmt::Debug for State<'a> {
48684868
write!(f, ", ")?;
48694869
}
48704870
if start == end {
4871-
write!(f, "{:?} => {:?}", start, id)?;
4871+
write!(f, "{start:?} => {id:?}")?;
48724872
} else {
4873-
write!(f, "{:?}-{:?} => {:?}", start, end, id)?;
4873+
write!(f, "{start:?}-{end:?} => {id:?}")?;
48744874
}
48754875
}
48764876
Ok(())
@@ -5135,7 +5135,7 @@ impl core::fmt::Display for BuildError {
51355135
match self.kind() {
51365136
BuildErrorKind::NFA(_) => write!(f, "error building NFA"),
51375137
BuildErrorKind::Unsupported(ref msg) => {
5138-
write!(f, "unsupported regex feature for DFAs: {}", msg)
5138+
write!(f, "unsupported regex feature for DFAs: {msg}")
51395139
}
51405140
BuildErrorKind::TooManyStates => write!(
51415141
f,
@@ -5167,11 +5167,10 @@ impl core::fmt::Display for BuildError {
51675167
),
51685168
BuildErrorKind::DFAExceededSizeLimit { limit } => write!(
51695169
f,
5170-
"DFA exceeded size limit of {:?} during determinization",
5171-
limit,
5170+
"DFA exceeded size limit of {limit:?} during determinization",
51725171
),
51735172
BuildErrorKind::DeterminizeExceededSizeLimit { limit } => {
5174-
write!(f, "determinization exceeded size limit of {:?}", limit)
5173+
write!(f, "determinization exceeded size limit of {limit:?}")
51755174
}
51765175
}
51775176
}

regex-automata/src/dfa/determinize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<'a> Runner<'a> {
280280
let per_elem = size_of::<StateID>() + size_of::<Vec<PatternID>>();
281281
let pats = total_pat_len * size_of::<PatternID>();
282282
let mem = (matches.len() * per_elem) + pats;
283-
log::debug!("matches map built, memory usage: {}", mem);
283+
log::debug!("matches map built, memory usage: {mem}");
284284
}
285285
// At this point, we shuffle the "special" states in the final DFA.
286286
// This permits a DFA's match loop to detect a match condition (among

regex-automata/src/dfa/onepass.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,7 +2408,7 @@ impl core::fmt::Debug for DFA {
24082408
}
24092409
write!(f, "{:06?}", sid.as_usize())?;
24102410
if !pateps.is_empty() {
2411-
write!(f, " ({:?})", pateps)?;
2411+
write!(f, " ({pateps:?})")?;
24122412
}
24132413
write!(f, ": ")?;
24142414
debug_state_transitions(f, self, sid)?;
@@ -2939,7 +2939,7 @@ impl core::fmt::Debug for Slots {
29392939
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
29402940
write!(f, "S")?;
29412941
for slot in self.iter() {
2942-
write!(f, "-{:?}", slot)?;
2942+
write!(f, "-{slot:?}")?;
29432943
}
29442944
Ok(())
29452945
}
@@ -3050,23 +3050,21 @@ impl core::fmt::Display for BuildError {
30503050
Word(_) => write!(f, "NFA contains Unicode word boundary"),
30513051
TooManyStates { limit } => write!(
30523052
f,
3053-
"one-pass DFA exceeded a limit of {:?} for number of states",
3054-
limit,
3053+
"one-pass DFA exceeded a limit of {limit:?} \
3054+
for number of states",
30553055
),
30563056
TooManyPatterns { limit } => write!(
30573057
f,
3058-
"one-pass DFA exceeded a limit of {:?} for number of patterns",
3059-
limit,
3058+
"one-pass DFA exceeded a limit of {limit:?} \
3059+
for number of patterns",
30603060
),
30613061
UnsupportedLook { look } => write!(
30623062
f,
3063-
"one-pass DFA does not support the {:?} assertion",
3064-
look,
3063+
"one-pass DFA does not support the {look:?} assertion",
30653064
),
30663065
ExceededSizeLimit { limit } => write!(
30673066
f,
3068-
"one-pass DFA exceeded size limit of {:?} during building",
3069-
limit,
3067+
"one-pass DFA exceeded size limit of {limit:?} during building",
30703068
),
30713069
NotOnePass { msg } => write!(
30723070
f,
@@ -3089,7 +3087,7 @@ mod tests {
30893087
let predicate = |err: &str| err.contains("conflicting transition");
30903088

30913089
let err = DFA::new(r"a*[ab]").unwrap_err().to_string();
3092-
assert!(predicate(&err), "{}", err);
3090+
assert!(predicate(&err), "{err}");
30933091
}
30943092

30953093
#[test]
@@ -3099,7 +3097,7 @@ mod tests {
30993097
};
31003098

31013099
let err = DFA::new(r"(^|$)a").unwrap_err().to_string();
3102-
assert!(predicate(&err), "{}", err);
3100+
assert!(predicate(&err), "{err}");
31033101
}
31043102

31053103
#[test]
@@ -3109,7 +3107,7 @@ mod tests {
31093107
};
31103108

31113109
let err = DFA::new_many(&[r"^", r"$"]).unwrap_err().to_string();
3112-
assert!(predicate(&err), "{}", err);
3110+
assert!(predicate(&err), "{err}");
31133111
}
31143112

31153113
// This test is meant to build a one-pass regex with the maximum number of

regex-automata/src/dfa/sparse.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ impl DFA<Vec<u8>> {
299299
);
300300
assert!(
301301
transition_len <= 257,
302-
"expected transition length {} to be <= 257",
303-
transition_len,
302+
"expected transition length {transition_len} to be <= 257",
304303
);
305304

306305
// Fill in the transition length.
@@ -2158,7 +2157,7 @@ impl<T: AsMut<[u8]>> StartTable<T> {
21582157
let len = self
21592158
.pattern_len
21602159
.expect("start states for each pattern enabled");
2161-
assert!(pid < len, "invalid pattern ID {:?}", pid);
2160+
assert!(pid < len, "invalid pattern ID {pid:?}");
21622161
self.stride
21632162
.checked_mul(pid)
21642163
.unwrap()

regex-automata/src/hybrid/dfa.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,8 +2598,8 @@ impl<'i, 'c> Lazy<'i, 'c> {
25982598
unit: alphabet::Unit,
25992599
to: LazyStateID,
26002600
) {
2601-
assert!(self.as_ref().is_valid(from), "invalid 'from' id: {:?}", from);
2602-
assert!(self.as_ref().is_valid(to), "invalid 'to' id: {:?}", to);
2601+
assert!(self.as_ref().is_valid(from), "invalid 'from' id: {from:?}");
2602+
assert!(self.as_ref().is_valid(to), "invalid 'to' id: {to:?}");
26032603
let offset =
26042604
from.as_usize_untagged() + self.dfa.classes.get_by_unit(unit);
26052605
self.cache.trans[offset] = to;
@@ -4080,10 +4080,9 @@ impl Builder {
40804080
// and mush on.
40814081
if self.config.get_skip_cache_capacity_check() {
40824082
debug!(
4083-
"given capacity ({}) is too small, \
4083+
"given capacity ({cache_capacity}) is too small, \
40844084
since skip_cache_capacity_check is enabled, \
4085-
setting cache capacity to minimum ({})",
4086-
cache_capacity, min_cache,
4085+
setting cache capacity to minimum ({min_cache})",
40874086
);
40884087
cache_capacity = min_cache;
40894088
} else {

regex-automata/src/hybrid/error.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,15 @@ impl core::fmt::Display for BuildError {
8080
BuildErrorKind::InsufficientCacheCapacity { minimum, given } => {
8181
write!(
8282
f,
83-
"given cache capacity ({}) is smaller than \
84-
minimum required ({})",
85-
given, minimum,
83+
"given cache capacity ({given}) is smaller than \
84+
minimum required ({minimum})",
8685
)
8786
}
8887
BuildErrorKind::InsufficientStateIDCapacity { ref err } => {
8988
err.fmt(f)
9089
}
9190
BuildErrorKind::Unsupported(ref msg) => {
92-
write!(f, "unsupported regex feature for DFAs: {}", msg)
91+
write!(f, "unsupported regex feature for DFAs: {msg}")
9392
}
9493
}
9594
}

regex-automata/src/meta/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl From<MatchError> for RetryFailError {
234234
// backtracker's wrapper will never hand out a backtracker engine
235235
// when the haystack would be too long.
236236
HaystackTooLong { .. } | UnsupportedAnchored { .. } => {
237-
unreachable!("found impossible error in meta engine: {}", merr)
237+
unreachable!("found impossible error in meta engine: {merr}")
238238
}
239239
}
240240
}

regex-automata/src/meta/limited.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ pub(crate) fn dfa_try_search_half_rev(
7878
at -= 1;
7979
if at < min_start {
8080
trace!(
81-
"reached position {} which is before the previous literal \
81+
"reached position {at} which is before the previous literal \
8282
match, quitting to avoid quadratic behavior",
83-
at,
8483
);
8584
return Err(RetryError::Quadratic(RetryQuadraticError::new()));
8685
}
@@ -114,9 +113,8 @@ pub(crate) fn dfa_try_search_half_rev(
114113
&& !was_dead
115114
{
116115
trace!(
117-
"reached beginning of search at offset {} without hitting \
116+
"reached beginning of search at offset {at} without hitting \
118117
a dead state, quitting to avoid potential false positive match",
119-
at,
120118
);
121119
return Err(RetryError::Quadratic(RetryQuadraticError::new()));
122120
}
@@ -161,9 +159,8 @@ pub(crate) fn hybrid_try_search_half_rev(
161159
at -= 1;
162160
if at < min_start {
163161
trace!(
164-
"reached position {} which is before the previous literal \
162+
"reached position {at} which is before the previous literal \
165163
match, quitting to avoid quadratic behavior",
166-
at,
167164
);
168165
return Err(RetryError::Quadratic(RetryQuadraticError::new()));
169166
}
@@ -176,9 +173,8 @@ pub(crate) fn hybrid_try_search_half_rev(
176173
&& !was_dead
177174
{
178175
trace!(
179-
"reached beginning of search at offset {} without hitting \
176+
"reached beginning of search at offset {at} without hitting \
180177
a dead state, quitting to avoid potential false positive match",
181-
at,
182178
);
183179
return Err(RetryError::Quadratic(RetryQuadraticError::new()));
184180
}

regex-automata/src/meta/literal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ pub(crate) fn alternation_literals(
5353
HirKind::Literal(Literal(ref bytes)) => {
5454
lit.extend_from_slice(bytes);
5555
}
56-
_ => unreachable!("expected literal, got {:?}", e),
56+
_ => unreachable!("expected literal, got {e:?}"),
5757
}
5858
}
5959
}
60-
_ => unreachable!("expected literal or concat, got {:?}", alt),
60+
_ => unreachable!("expected literal or concat, got {alt:?}"),
6161
}
6262
lits.push(lit);
6363
}

0 commit comments

Comments
 (0)