Skip to content

Commit cd6a718

Browse files
committed
Switch to 2024 Rust edition
- bump up MSRV to 1.85 - tune lints for 1.85 Rust - revisit `rustfmt` rules
1 parent 3737dc6 commit cd6a718

File tree

12 files changed

+83
-105
lines changed

12 files changed

+83
-105
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
strategy:
102102
fail-fast: false
103103
matrix:
104-
msrv: ["1.81.0"]
104+
msrv: ["1.85.0"]
105105
os: ["ubuntu", "macOS", "windows"]
106106
runs-on: ${{ matrix.os }}-latest
107107
steps:

.rustfmt.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md
44

55
max_width = 80
6-
format_strings = false
6+
use_small_heuristics = "Max"
7+
8+
group_imports = "StdExternalCrate"
79
imports_granularity = "Crate"
810

11+
format_strings = false
912
format_code_in_doc_comments = true
1013
format_macro_matchers = true
1114
use_try_shorthand = true

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ All user visible changes to `cucumber-expressions` crate will be documented in t
66

77

88

9+
## main
10+
11+
[Diff](https://github.com/cucumber-rs/cucumber-expressions/compare/v0.4.0...main)
12+
13+
### BC Breaks
14+
15+
- Bumped up [MSRV] to 1.85 because of migration to 2024 edition. ([todo])
16+
17+
[todo]: https://github.com/cucumber-rs/cucumber-expressions/commit/todo
18+
19+
20+
21+
922
## [0.4.0] · 2025-02-03
1023
[0.4.0]: https://github.com/cucumber-rs/cucumber-expressions/tree/v0.4.0
1124

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "cucumber-expressions"
33
version = "0.4.0"
4-
edition = "2021"
5-
rust-version = "1.81"
4+
edition = "2024"
5+
rust-version = "1.85"
66
description = "Cucumber Expressions AST and parser."
77
license = "MIT OR Apache-2.0"
88
authors = [

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
===============================
33

44
[![crates.io](https://img.shields.io/crates/v/cucumber-expressions.svg?maxAge=2592000 "crates.io")](https://crates.io/crates/cucumber-expressions)
5-
[![Rust 1.81+](https://img.shields.io/badge/rustc-1.81+-lightgray.svg "Rust 1.81+")](https://blog.rust-lang.org/2024/09/05/Rust-1.81.0.html)
5+
[![Rust 1.85+](https://img.shields.io/badge/rustc-1.85+-lightgray.svg "Rust 1.85+")](https://blog.rust-lang.org/2025/02/20/Rust-1.85.0.html)
66
[![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg "Unsafe forbidden")](https://github.com/rust-secure-code/safety-dance)
77
[![CI](https://github.com/cucumber-rs/cucumber-expressions/actions/workflows/ci.yml/badge.svg?branch=main "CI")](https://github.com/cucumber-rs/cucumber-expressions/actions?query=workflow%3ACI+branch%3Amain)
88
[![Rust docs](https://docs.rs/cucumber-expressions/badge.svg "Rust docs")](https://docs.rs/cucumber-expressions)

fuzz/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[package]
22
name = "cucumber-expressions-fuzz"
33
version = "0.0.0"
4-
edition = "2021"
5-
rust-version = "1.81"
4+
edition = "2024"
5+
rust-version = "1.85"
66
description = "Fuzz testing for `cucumber-expressions` crate."
77
license = "MIT OR Apache-2.0"
88
authors = [

src/ast.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! [AST]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
1818
1919
use derive_more::with_trait::{AsRef, Deref, DerefMut};
20-
use nom::{error::ErrorKind, Err, Input};
20+
use nom::{Err, Input, error::ErrorKind};
2121
use nom_locate::LocatedSpan;
2222

2323
use crate::parse;
@@ -131,9 +131,7 @@ impl<I: Input> Alternation<I> {
131131
/// [`Optional`]s.
132132
pub(crate) fn contains_only_optional(&self) -> bool {
133133
(**self).iter().any(|single_alt| {
134-
single_alt
135-
.iter()
136-
.all(|alt| matches!(alt, Alternative::Optional(_)))
134+
single_alt.iter().all(|alt| matches!(alt, Alternative::Optional(_)))
137135
})
138136
}
139137
}

src/combinator.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//! Helper parser combinators.
1212
1313
use nom::{
14-
error::{ErrorKind, ParseError},
1514
AsChar, Err, IResult, Input, Offset, Parser,
15+
error::{ErrorKind, ParseError},
1616
};
1717

1818
/// Applies the given `map` function to the `parser`'s [`IResult`] in case it
@@ -44,13 +44,13 @@ where
4444
/// non-`escapable` `Input` or end of line.
4545
///
4646
/// [`escaped()`]: nom::bytes::complete::escaped()
47-
pub(crate) fn escaped0<'a, I, Error, F, G>(
47+
pub(crate) fn escaped0<I, Error, F, G>(
4848
mut normal: F,
4949
control_char: char,
5050
mut escapable: G,
5151
) -> impl FnMut(I) -> IResult<I, I, Error>
5252
where
53-
I: Clone + Offset + Input + 'a,
53+
I: Clone + Offset + Input,
5454
<I as Input>::Item: AsChar,
5555
F: Parser<I, Error = Error>,
5656
G: Parser<I, Error = Error>,
@@ -130,10 +130,10 @@ where
130130
#[cfg(test)]
131131
mod escaped0_spec {
132132
use nom::{
133+
Err, IResult,
133134
bytes::complete::escaped,
134135
character::complete::{digit0, digit1, one_of},
135136
error::{Error, ErrorKind},
136-
Err, IResult,
137137
};
138138

139139
use super::escaped0;

src/expand/mod.rs

+10-23
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ use either::Either;
2626
use nom::{AsChar, Input};
2727
use regex::Regex;
2828

29-
use crate::{
30-
parse, Alternation, Alternative, Expression, Optional, Parameter,
31-
SingleAlternation, SingleExpression, Spanned,
32-
};
33-
3429
pub use self::parameters::{
3530
Provider as ParametersProvider, WithCustom as WithCustomParameters,
3631
};
32+
use crate::{
33+
Alternation, Alternative, Expression, Optional, Parameter,
34+
SingleAlternation, SingleExpression, Spanned, parse,
35+
};
3736

3837
impl<'s> Expression<Spanned<'s>> {
3938
/// Parses the given `input` as an [`Expression`], and immediately expands
@@ -93,11 +92,9 @@ impl<'s> Expression<Spanned<'s>> {
9392
/// &parameters,
9493
/// )
9594
/// .unwrap();
95+
/// let re = re.as_str();
9696
///
97-
/// assert_eq!(
98-
/// re.as_str(),
99-
/// "^([^\\s]+) has ([Rr]ed|[Gg]reen|[Bb]lue) eyes$",
100-
/// );
97+
/// assert_eq!(re, "^([^\\s]+) has ([Rr]ed|[Gg]reen|[Bb]lue) eyes$");
10198
/// ```
10299
///
103100
/// [`Error`]: enum@Error
@@ -128,10 +125,7 @@ impl<'s> Expression<Spanned<'s>> {
128125
self,
129126
parameters: P,
130127
) -> WithCustomParameters<Self, P> {
131-
WithCustomParameters {
132-
element: self,
133-
parameters,
134-
}
128+
WithCustomParameters { element: self, parameters }
135129
}
136130
}
137131

@@ -488,18 +482,14 @@ where
488482
Iter::Item: Clone,
489483
{
490484
fn clone(&self) -> Self {
491-
Self {
492-
iter: self.iter.clone(),
493-
}
485+
Self { iter: self.iter.clone() }
494486
}
495487
}
496488

497489
impl<Iter: Iterator> SkipLast<Iter> {
498490
/// Creates a new [`SkipLast`] [`Iterator`].
499491
pub fn new(iter: Iter) -> Self {
500-
Self {
501-
iter: iter.peekable(),
502-
}
492+
Self { iter: iter.peekable() }
503493
}
504494
}
505495

@@ -572,10 +562,7 @@ pub struct EscapeForRegex<Iter: Iterator> {
572562
impl<Iter: Iterator> EscapeForRegex<Iter> {
573563
/// Creates a new [`EscapeForRegex`] [`Iterator`].
574564
pub fn new(iter: Iter) -> Self {
575-
Self {
576-
iter: iter.peekable(),
577-
was_escaped: None,
578-
}
565+
Self { iter: iter.peekable(), was_escaped: None }
579566
}
580567
}
581568

src/expand/parameters.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ use std::{collections::HashMap, fmt::Display, iter, str, vec};
1717
use either::Either;
1818
use nom::{AsChar, Input};
1919

20-
use crate::{expand::OwnedChars, Parameter, SingleExpression};
21-
2220
use super::{
2321
Expression, IntoRegexCharIter, ParameterError, ParameterIter,
2422
SingleExpressionIter,
2523
};
24+
use crate::{Parameter, SingleExpression, expand::OwnedChars};
2625

2726
/// Parser of a [Cucumber Expressions][0] [AST] `Element` with [custom][1]
2827
/// `Parameters` in mind.
@@ -106,10 +105,8 @@ where
106105
type Iter = ExpressionWithParsIter<I, Pars>;
107106

108107
fn into_regex_char_iter(self) -> Self::Iter {
109-
let add_pars: fn(_) -> _ = |(item, parameters)| WithCustom {
110-
element: item,
111-
parameters,
112-
};
108+
let add_pars: fn(_) -> _ =
109+
|(item, parameters)| WithCustom { element: item, parameters };
113110
let into_regex_char_iter: fn(_) -> _ =
114111
IntoRegexCharIter::into_regex_char_iter;
115112
iter::once(Ok('^'))
@@ -161,11 +158,8 @@ where
161158

162159
if let SingleExpression::Parameter(item) = self.element {
163160
Left(
164-
WithCustom {
165-
element: item,
166-
parameters: self.parameters,
167-
}
168-
.into_regex_char_iter(),
161+
WithCustom { element: item, parameters: self.parameters }
162+
.into_regex_char_iter(),
169163
)
170164
} else {
171165
Right(self.element.into_regex_char_iter())
@@ -383,9 +377,8 @@ mod regex_hir {
383377

384378
#[cfg(test)]
385379
mod spec {
386-
use crate::expand::Error;
387-
388380
use super::{Expression, HashMap, ParameterError};
381+
use crate::expand::Error;
389382

390383
#[test]
391384
fn custom_parameter() {

src/lib.rs

+12-19
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,17 @@
1212
html_logo_url = "https://avatars.githubusercontent.com/u/91469139?s=128",
1313
html_favicon_url = "https://avatars.githubusercontent.com/u/91469139?s=256"
1414
)]
15-
#![doc = include_str!("../README.md")]
1615
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
17-
#![deny(
18-
macro_use_extern_crate,
19-
nonstandard_style,
20-
rust_2018_idioms,
21-
rustdoc::all,
22-
trivial_casts,
23-
trivial_numeric_casts
24-
)]
16+
#![cfg_attr(any(doc, test), doc = include_str!("../README.md"))]
17+
#![cfg_attr(not(any(doc, test)), doc = env!("CARGO_PKG_NAME"))]
18+
#![deny(nonstandard_style, rustdoc::all, trivial_casts, trivial_numeric_casts)]
2519
#![forbid(non_ascii_idents, unsafe_code)]
2620
#![warn(
2721
clippy::absolute_paths,
2822
clippy::allow_attributes,
2923
clippy::allow_attributes_without_reason,
3024
clippy::as_conversions,
25+
clippy::as_pointer_underscore,
3126
clippy::as_ptr_cast_mut,
3227
clippy::assertions_on_result_states,
3328
clippy::branches_sharing_code,
@@ -41,6 +36,7 @@
4136
clippy::decimal_literal_representation,
4237
clippy::default_union_representation,
4338
clippy::derive_partial_eq_without_eq,
39+
clippy::doc_include_without_cfg,
4440
clippy::else_if_without_else,
4541
clippy::empty_drop,
4642
clippy::empty_structs_with_brackets,
@@ -64,6 +60,7 @@
6460
clippy::large_include_file,
6561
clippy::large_stack_frames,
6662
clippy::let_underscore_untyped,
63+
clippy::literal_string_with_formatting_args,
6764
clippy::lossy_float_literal,
6865
clippy::map_err_ignore,
6966
clippy::map_with_unused_argument_over_ranges,
@@ -140,29 +137,25 @@
140137
clippy::verbose_file_reads,
141138
clippy::while_float,
142139
clippy::wildcard_enum_match_arm,
143-
explicit_outlives_requirements,
140+
ambiguous_negative_literals,
141+
closure_returning_async_block,
144142
future_incompatible,
143+
impl_trait_redundant_captures,
145144
let_underscore_drop,
145+
macro_use_extern_crate,
146146
meta_variable_misuse,
147147
missing_abi,
148148
missing_copy_implementations,
149149
missing_debug_implementations,
150150
missing_docs,
151151
redundant_lifetimes,
152-
semicolon_in_expressions_from_macros,
152+
rust_2018_idioms,
153153
single_use_lifetimes,
154154
unit_bindings,
155155
unnameable_types,
156156
unreachable_pub,
157-
unsafe_op_in_unsafe_fn,
158157
unstable_features,
159-
unused_crate_dependencies,
160-
unused_extern_crates,
161-
unused_import_braces,
162-
unused_lifetimes,
163-
unused_macro_rules,
164-
unused_qualifications,
165-
unused_results,
158+
unused,
166159
variant_size_differences
167160
)]
168161

0 commit comments

Comments
 (0)