Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions regex-cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ impl std::str::FromStr for ByteSet {
for &byte in Vec::unescape_bytes(s).iter() {
anyhow::ensure!(
!seen[usize::from(byte)],
"saw duplicate byte 0x{:2X} in '{}'",
byte,
s,
"saw duplicate byte 0x{byte:2X} in '{s}'",
);
seen[usize::from(byte)] = true;
set.push(byte);
Expand Down Expand Up @@ -96,7 +94,7 @@ impl std::str::FromStr for StartKind {
"both" => regex_automata::dfa::StartKind::Both,
"unanchored" => regex_automata::dfa::StartKind::Unanchored,
"anchored" => regex_automata::dfa::StartKind::Anchored,
unk => anyhow::bail!("unrecognized start kind '{}'", unk),
unk => anyhow::bail!("unrecognized start kind '{unk}'"),
};
Ok(StartKind { kind })
}
Expand Down Expand Up @@ -147,7 +145,7 @@ impl std::str::FromStr for MatchKind {
let kind = match s {
"leftmost-first" => regex_automata::MatchKind::LeftmostFirst,
"all" => regex_automata::MatchKind::All,
unk => anyhow::bail!("unrecognized match kind '{}'", unk),
unk => anyhow::bail!("unrecognized match kind '{unk}'"),
};
Ok(MatchKind { kind })
}
Expand Down
4 changes: 2 additions & 2 deletions regex-cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ pub fn next_as_command(usage: &str, p: &mut Parser) -> anyhow::Result<String> {
let usage = usage.trim();
let arg = match p.next()? {
Some(arg) => arg,
None => anyhow::bail!("{}", usage),
None => anyhow::bail!("{usage}"),
};
let cmd = match arg {
Arg::Value(cmd) => cmd.string()?,
Arg::Short('h') | Arg::Long("help") => anyhow::bail!("{}", usage),
Arg::Short('h') | Arg::Long("help") => anyhow::bail!("{usage}"),
arg => return Err(arg.unexpected().into()),
};
Ok(cmd)
Expand Down
7 changes: 2 additions & 5 deletions regex-cli/args/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Config {
.map(|(i, p)| {
let p = p.as_ref();
self.ast(p).with_context(|| {
format!("failed to parse pattern {} to AST: '{}'", i, p,)
format!("failed to parse pattern {i} to AST: '{p}'",)
})
})
.collect()
Expand Down Expand Up @@ -80,10 +80,7 @@ impl Config {
.map(|(i, (pat, ast))| {
let (pat, ast) = (pat.as_ref(), ast.borrow());
self.hir(pat, ast).with_context(|| {
format!(
"failed to translate pattern {} to HIR: '{}'",
i, pat,
)
format!("failed to translate pattern {i} to HIR: '{pat}'",)
})
})
.collect()
Expand Down
16 changes: 7 additions & 9 deletions regex-cli/cmd/compile_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ OPTIONS:
} else {
write!(wtr, "regex,")?;
}
write!(wtr, "{},", revision)?;
write!(wtr, "{revision},")?;
write!(wtr, "{},", tdir.test.profile.as_str())?;
write!(wtr, "{:?},", m.duration)?;
write!(wtr, "{:?},", m.size)?;
write!(wtr, "{:?}", relative_size)?;
write!(wtr, "{relative_size:?}")?;
write!(wtr, "\n")?;
}
Ok(())
Expand Down Expand Up @@ -439,7 +439,7 @@ impl Test {
let features = self
.features
.iter()
.map(|f| format!(r#""{}""#, f))
.map(|f| format!(r#""{f}""#))
.collect::<Vec<String>>()
.join(", ");
format!(
Expand Down Expand Up @@ -480,7 +480,7 @@ strip = "symbols"
let features = self
.features
.iter()
.map(|f| format!(r#""{}""#, f))
.map(|f| format!(r#""{f}""#))
.collect::<Vec<String>>()
.join(", ");
format!(
Expand Down Expand Up @@ -521,7 +521,7 @@ strip = "symbols"
let features = self
.features
.iter()
.map(|f| format!(r#""{}""#, f))
.map(|f| format!(r#""{f}""#))
.collect::<Vec<String>>()
.join(", ");
format!(
Expand Down Expand Up @@ -800,8 +800,7 @@ fn baseline_size(parent_dir: &Path, profile: Profile) -> anyhow::Result<u64> {
.with_context(|| format!("'cargo clean' failed for baseline"))?;
anyhow::ensure!(
status.success(),
"'cargo clean' got an error exit code of {:?} for baseline",
status,
"'cargo clean' got an error exit code of {status:?} for baseline",
);
let status = Command::new("cargo")
.arg("build")
Expand All @@ -814,8 +813,7 @@ fn baseline_size(parent_dir: &Path, profile: Profile) -> anyhow::Result<u64> {
.with_context(|| format!("'cargo build' failed for baseline"))?;
anyhow::ensure!(
status.success(),
"'cargo build' got an error exit code of {:?} for baseline",
status,
"'cargo build' got an error exit code of {status:?} for baseline",
);
let bin = dir
.join("target")
Expand Down
12 changes: 6 additions & 6 deletions regex-cli/cmd/debug/dfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ COMMANDS:
match &*cmd {
"dfa" => run_dense_dfa(p),
"regex" => run_dense_regex(p),
unk => anyhow::bail!("unrecognized command '{}'", unk),
unk => anyhow::bail!("unrecognized command '{unk}'"),
}
}

Expand Down Expand Up @@ -88,7 +88,7 @@ OPTIONS:
if common.table() {
writeln!(stdout(), "")?;
}
writeln!(stdout(), "{:?}", dfa)?;
writeln!(stdout(), "{dfa:?}")?;
}
Ok(())
}
Expand Down Expand Up @@ -161,7 +161,7 @@ OPTIONS:
if common.table() {
writeln!(stdout(), "")?;
}
writeln!(stdout(), "{:?}", re)?;
writeln!(stdout(), "{re:?}")?;
}
Ok(())
}
Expand All @@ -188,7 +188,7 @@ COMMANDS:
match &*cmd {
"dfa" => run_sparse_dfa(p),
"regex" => run_sparse_regex(p),
unk => anyhow::bail!("unrecognized command '{}'", unk),
unk => anyhow::bail!("unrecognized command '{unk}'"),
}
}

Expand Down Expand Up @@ -245,7 +245,7 @@ OPTIONS:
if common.table() {
writeln!(stdout(), "")?;
}
writeln!(stdout(), "{:?}", dfa)?;
writeln!(stdout(), "{dfa:?}")?;
}
Ok(())
}
Expand Down Expand Up @@ -320,7 +320,7 @@ OPTIONS:
if common.table() {
writeln!(stdout(), "")?;
}
writeln!(stdout(), "{:?}", re)?;
writeln!(stdout(), "{re:?}")?;
}
Ok(())
}
10 changes: 4 additions & 6 deletions regex-cli/cmd/debug/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ OPTIONS:
ExtractKind::Suffix => seq.optimize_for_suffix_by_preference(),
unk => {
anyhow::bail!(
"unsupported literal extraction kind: {:?}",
unk
"unsupported literal extraction kind: {unk:?}"
)
}
}
Expand Down Expand Up @@ -95,10 +94,10 @@ OPTIONS:
writeln!(out, "")?;
}
match seq.literals() {
None => writeln!(out, "{:?}", seq)?,
None => writeln!(out, "{seq:?}")?,
Some(literals) => {
for lit in literals.iter() {
writeln!(stdout(), "{:?}", lit)?;
writeln!(stdout(), "{lit:?}")?;
}
}
}
Expand Down Expand Up @@ -127,8 +126,7 @@ impl Configurable for Literal {
"prefix" => ExtractKind::Prefix,
"suffix" => ExtractKind::Suffix,
unk => anyhow::bail!(
"unknown value for --extract-kind: {}",
unk
"unknown value for --extract-kind: {unk}"
),
};
self.kind = kind.clone();
Expand Down
6 changes: 3 additions & 3 deletions regex-cli/cmd/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ COMMANDS:
"onepass" => run_onepass(p),
"sparse" => dfa::run_sparse(p),
"thompson" => run_thompson(p),
unk => anyhow::bail!("unrecognized command '{}'", unk),
unk => anyhow::bail!("unrecognized command '{unk}'"),
}
}

Expand Down Expand Up @@ -181,7 +181,7 @@ OPTIONS:
if common.table() {
writeln!(stdout(), "")?;
}
writeln!(stdout(), "{:?}", dfa)?;
writeln!(stdout(), "{dfa:?}")?;
}
Ok(())
}
Expand Down Expand Up @@ -238,7 +238,7 @@ OPTIONS:
if common.table() {
writeln!(stdout(), "")?;
}
writeln!(stdout(), "{:?}", nfa)?;
writeln!(stdout(), "{nfa:?}")?;
}
Ok(())
}
10 changes: 5 additions & 5 deletions regex-cli/cmd/find/capture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ENGINES:
"onepass" => dfa::run_onepass(p),
"pikevm" => nfa::run_pikevm(p),
"regex" => run_regex(p),
unk => anyhow::bail!("unrecognized command '{}'", unk),
unk => anyhow::bail!("unrecognized command '{unk}'"),
}
}

Expand Down Expand Up @@ -388,9 +388,9 @@ fn run_counts(
}
let count = pattern_counts[group_index];
if let Some(name) = maybe_name {
write!(out, "{}/{}: {}", group_index, name, count)?;
write!(out, "{group_index}/{name}: {count}")?;
} else {
write!(out, "{}: {}", group_index, count)?;
write!(out, "{group_index}: {count}")?;
}
}
write!(out, " }}\n")?;
Expand Down Expand Up @@ -440,9 +440,9 @@ fn run_search(
write!(out, ", ")?;
}
if let Some(name) = maybe_name {
write!(out, "{}/{}: ", group_index, name)?;
write!(out, "{group_index}/{name}: ")?;
} else {
write!(out, "{}: ", group_index)?;
write!(out, "{group_index}: ")?;
}
match caps.get_group(group_index) {
None => write!(out, "NONE")?,
Expand Down
2 changes: 1 addition & 1 deletion regex-cli/cmd/find/half/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ENGINES:
"meta" => run_meta(p),
"regex" => run_regex(p),
"sparse" => dfa::run_sparse(p),
unk => anyhow::bail!("unrecognized command '{}'", unk),
unk => anyhow::bail!("unrecognized command '{unk}'"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion regex-cli/cmd/find/match/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ENGINES:
"pikevm" => nfa::run_pikevm(p),
"regex" => run_regex(p),
"sparse" => dfa::run_sparse(p),
unk => anyhow::bail!("unrecognized command '{}'", unk),
unk => anyhow::bail!("unrecognized command '{unk}'"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion regex-cli/cmd/find/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ COMMANDS:
"half" => half::run(p),
"match" => r#match::run(p),
"which" => which::run(p),
unk => anyhow::bail!("unrecognized command '{}'", unk),
unk => anyhow::bail!("unrecognized command '{unk}'"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion regex-cli/cmd/find/which/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ENGINES:
"pikevm" => nfa::run_pikevm(p),
"regex" => run_regex(p),
"sparse" => dfa::run_sparse(p),
unk => anyhow::bail!("unrecognized command '{}'", unk),
unk => anyhow::bail!("unrecognized command '{unk}'"),
}
}

Expand Down
Loading
Loading