Skip to content

Commit 6a45956

Browse files
committed
update to edition 2024
1 parent b29cb17 commit 6a45956

File tree

41 files changed

+142
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+142
-181
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ members = [
1010
]
1111
default-members = ["./pomsky-bin", "./pomsky-lib", "./pomsky-syntax"]
1212
resolver = "2"
13-
package.edition = "2021"
13+
package.edition = "2024"
1414

1515
[profile.release]
1616
lto = "thin"

benchmark/benches/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use pomsky::{diagnose::Diagnostic, options::CompileOptions, Expr};
1+
use pomsky::{Expr, diagnose::Diagnostic, options::CompileOptions};
22

33
const STRINGS: &str = include_str!("./files/strings.pomsky");
44
const PROPERTIES: &str = include_str!("./files/properties.pomsky");
@@ -21,7 +21,7 @@ macro_rules! items {
2121

2222
#[divan::bench_group]
2323
mod parse {
24-
use divan::{counter::BytesCount, Bencher};
24+
use divan::{Bencher, counter::BytesCount};
2525
use pomsky::Expr;
2626

2727
macro_rules! group_item {
@@ -56,8 +56,8 @@ mod parse {
5656
mod compile {
5757
use divan::Bencher;
5858
use pomsky::{
59-
options::{CompileOptions, RegexFlavor},
6059
Expr,
60+
options::{CompileOptions, RegexFlavor},
6161
};
6262

6363
fn ruby() -> CompileOptions {
@@ -97,7 +97,7 @@ mod compile {
9797

9898
#[divan::bench(args = 1..=13)]
9999
pub fn range(bencher: divan::Bencher, n: usize) {
100-
let max = "3458709621".repeat((n + 9) / 10);
100+
let max = "3458709621".repeat(n.div_ceil(10));
101101
let max = &max[..n];
102102
let input = format!("range '0'-'{max}'");
103103

pomsky-bin/src/args/help.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use helptext::{sections, Help, HelpSection};
1+
use helptext::{Help, HelpSection, sections};
22
use supports_color::Stream;
33

44
const USAGE: Help = Help(sections![

pomsky-bin/src/args/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::io::{stdin, stdout, IsTerminal};
1+
use std::io::{IsTerminal, stdin, stdout};
22
use std::path::PathBuf;
33

44
use pomsky::{features::PomskyFeatures, options::RegexFlavor};

pomsky-bin/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pub use result::{
1515
use std::{path::Path, process::exit, time::Instant};
1616

1717
use pomsky::{
18-
options::{CompileOptions as PomskyCompileOptions, RegexFlavor},
1918
Expr,
19+
options::{CompileOptions as PomskyCompileOptions, RegexFlavor},
2020
};
2121

2222
use args::{CompileOptions, GlobalOptions, Input};

pomsky-bin/src/result/serde_code.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use pomsky::diagnose::DiagnosticCode;
22
use serde::{
3-
de::{Error, Expected, Unexpected, Visitor},
43
Deserializer, Serializer,
4+
de::{Error, Expected, Unexpected, Visitor},
55
};
66

77
pub(super) fn serialize<S>(value: &Option<DiagnosticCode>, serializer: S) -> Result<S::Ok, S::Error>

pomsky-bin/src/test_runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::ops::Index;
22

33
use pcre2::bytes::Regex as PcreRegex;
44
use pomsky::{
5+
Expr,
56
diagnose::{Diagnostic, DiagnosticCode, Severity},
67
features::PomskyFeatures,
78
options::CompileOptions,
89
test::{CaptureIdent, TestCase, TestCaseMatch, TestCaseMatchAll, TestCaseReject},
9-
Expr,
1010
};
1111
use regex::Regex as RustRegex;
1212

pomsky-bin/src/testing.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use helptext::text;
44
use pomsky::options::RegexFlavor;
55

66
use crate::{
7+
CompilationResult,
78
args::{CompileOptions, GlobalOptions, Input, RegexEngine, TestOptions},
89
format::Logger,
9-
CompilationResult,
1010
};
1111

1212
pub(crate) struct TestDirectoryResult {
@@ -120,21 +120,13 @@ fn test_directory(
120120
.filter_entry(is_dir_or_pomsky_file)
121121
.build()
122122
{
123-
if let Ok(entry) = entry.map_err(|d| handle_walk_error(d, logger, current_dir)) {
124-
if entry.file_type().is_some_and(|ty| ty.is_file()) {
125-
total += 1;
123+
if let Ok(entry) = entry.map_err(|d| handle_walk_error(d, logger, current_dir))
124+
&& entry.file_type().is_some_and(|ty| ty.is_file())
125+
{
126+
total += 1;
126127

127-
let path = entry.path();
128-
test_single(
129-
logger,
130-
path,
131-
current_dir,
132-
args,
133-
compile_args,
134-
&mut results,
135-
&mut failed,
136-
);
137-
}
128+
let path = entry.path();
129+
test_single(logger, path, current_dir, args, compile_args, &mut results, &mut failed);
138130
};
139131
}
140132

pomsky-bin/tests/e2e.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,9 @@ impl predicates::Predicate<[u8]> for Output {
4949
}
5050
}
5151

52-
fn find_case(&self, expected: bool, variable: &[u8]) -> Option<Case> {
52+
fn find_case(&self, expected: bool, variable: &[u8]) -> Option<Case<'_>> {
5353
let actual = self.eval(variable);
54-
if expected == actual {
55-
Some(Case::new(Some(self), actual))
56-
} else {
57-
None
58-
}
54+
if expected == actual { Some(Case::new(Some(self), actual)) } else { None }
5955
}
6056
}
6157

pomsky-lib/src/diagnose/compile_error.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use pomsky_syntax::{
2-
diagnose::{ParseError, ParseErrorKind},
32
Span,
3+
diagnose::{ParseError, ParseErrorKind},
44
};
55

66
use crate::{exprs::char_class::RegexCharSetItem, options::RegexFlavor};
@@ -210,7 +210,10 @@ impl core::fmt::Display for CompileErrorKind {
210210
write!(f, "Unit tests may only appear at the top level of the expression")
211211
}
212212
CompileErrorKind::UnsupportedInLookbehind { flavor, feature } => {
213-
write!(f, "Feature `{feature:?}` is not supported within lookbehinds in the {flavor:?} flavor")
213+
write!(
214+
f,
215+
"Feature `{feature:?}` is not supported within lookbehinds in the {flavor:?} flavor"
216+
)
214217
}
215218
CompileErrorKind::LookbehindNotConstantLength { flavor } => match flavor {
216219
RegexFlavor::Pcre | RegexFlavor::Python => write!(

0 commit comments

Comments
 (0)