Skip to content

Commit

Permalink
Merge pull request #548 from epage/update
Browse files Browse the repository at this point in the history
chore: Upgrade winnow
  • Loading branch information
epage committed Apr 28, 2023
2 parents bd4bde0 + dee5639 commit b1430ac
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.60.0" # MSRV
msrv = "1.64.0" # MSRV
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ jobs:
- name: toml (no-default features)
run: cargo test -p toml --no-default-features
msrv:
name: "Check MSRV: 1.60.0"
name: "Check MSRV: 1.64.0"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0 # MSRV
toolchain: 1.64.0 # MSRV
profile: minimal
override: true
- uses: Swatinem/rust-cache@v2
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0 # MSRV
toolchain: 1.64.0 # MSRV
profile: minimal
override: true
components: clippy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ jobs:
strategy:
matrix:
rust:
- 1.60.0 # MSRV
- 1.64.0 # MSRV
- stable
continue-on-error: ${{ matrix.rust != '1.60.0' }} # MSRV
continue-on-error: ${{ matrix.rust != '1.64.0' }} # MSRV
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "toml_benchmarks"
version = "0.0.0"
publish = false
edition = "2021"
rust-version = "1.60.0" # MSRV
rust-version = "1.64.0" # MSRV

[package.metadata.release]
release = false
Expand Down
2 changes: 1 addition & 1 deletion crates/serde_spanned/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/toml-rs/toml"
homepage = "https://github.com/toml-rs/toml"
documentation = "https://docs.rs/serde_spanned"
edition = "2021"
rust-version = "1.60.0" # MSRV
rust-version = "1.64.0" # MSRV
include = [
"src/**/*",
"Cargo.toml",
Expand Down
2 changes: 1 addition & 1 deletion crates/serde_toml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/toml-rs/toml"
homepage = "https://github.com/toml-rs/toml"
documentation = "https://docs.rs/toml"
edition = "2021"
rust-version = "1.60.0" # MSRV
rust-version = "1.64.0" # MSRV
include = [
"src/**/*",
"Cargo.toml",
Expand Down
2 changes: 1 addition & 1 deletion crates/toml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repository = "https://github.com/toml-rs/toml"
homepage = "https://github.com/toml-rs/toml"
documentation = "https://docs.rs/toml"
edition = "2021"
rust-version = "1.60.0" # MSRV
rust-version = "1.64.0" # MSRV
include = [
"src/**/*",
"Cargo.toml",
Expand Down
2 changes: 1 addition & 1 deletion crates/toml_datetime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/toml-rs/toml"
homepage = "https://github.com/toml-rs/toml"
documentation = "https://docs.rs/toml_datetime"
edition = "2021"
rust-version = "1.60.0" # MSRV
rust-version = "1.64.0" # MSRV
include = [
"src/**/*",
"Cargo.toml",
Expand Down
4 changes: 2 additions & 2 deletions crates/toml_edit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = ["Andronik Ordian <write@reusable.software>", "Ed Page <eopage@gmail.c
repository = "https://github.com/ordian/toml_edit"
documentation = "https://docs.rs/toml_edit"
edition = "2021"
rust-version = "1.60.0" # MSRV
rust-version = "1.64.0" # MSRV
include = [
"src/**/*",
"Cargo.toml",
Expand Down Expand Up @@ -48,7 +48,7 @@ unbounded = []

[dependencies]
indexmap = { version = "1.9.1", features = ["std"] }
winnow = "0.4.0"
winnow = "0.4.3"
serde = { version = "1.0.145", optional = true }
kstring = { version = "2.0.0", features = ["max_inline"], optional = true }
toml_datetime = { version = "0.6.1", path = "../toml_datetime" }
Expand Down
6 changes: 3 additions & 3 deletions crates/toml_edit/src/parser/array.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use winnow::combinator::cut_err;
use winnow::combinator::delimited;
use winnow::combinator::opt;
use winnow::multi::separated1;
use winnow::sequence::delimited;
use winnow::combinator::separated1;

use crate::parser::trivia::ws_comment_newline;
use crate::parser::value::value;
Expand Down Expand Up @@ -57,7 +57,7 @@ pub(crate) fn array_values(
),
ws_comment_newline.span(),
)
.map_res::<_, _, std::str::Utf8Error>(|(array, trailing)| {
.try_map::<_, _, std::str::Utf8Error>(|(array, trailing)| {
let (mut array, comma) = array.unwrap_or_default();
array.set_trailing_comma(comma);
array.set_trailing(RawString::with_span(trailing));
Expand Down
22 changes: 11 additions & 11 deletions crates/toml_edit/src/parser/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use crate::parser::prelude::*;
use crate::parser::trivia::from_utf8_unchecked;

use toml_datetime::*;
use winnow::branch::alt;
use winnow::bytes::one_of;
use winnow::bytes::take_while_m_n;
use winnow::combinator::alt;
use winnow::combinator::cut_err;
use winnow::combinator::opt;
use winnow::sequence::preceded;
use winnow::combinator::preceded;
use winnow::token::one_of;
use winnow::token::take_while;

// ;; Date and Time (as defined in RFC 3339)

Expand Down Expand Up @@ -104,7 +104,7 @@ pub(crate) fn date_fullyear(input: Input<'_>) -> IResult<Input<'_>, u16, ParserE
// date-month = 2DIGIT ; 01-12
pub(crate) fn date_month(input: Input<'_>) -> IResult<Input<'_>, u8, ParserError<'_>> {
unsigned_digits::<2, 2>
.map_res(|s: &str| {
.try_map(|s: &str| {
let d = s.parse::<u8>().expect("2DIGIT should match u8");
if (1..=12).contains(&d) {
Ok(d)
Expand All @@ -118,7 +118,7 @@ pub(crate) fn date_month(input: Input<'_>) -> IResult<Input<'_>, u8, ParserError
// date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on month/year
pub(crate) fn date_mday(input: Input<'_>) -> IResult<Input<'_>, u8, ParserError<'_>> {
unsigned_digits::<2, 2>
.map_res(|s: &str| {
.try_map(|s: &str| {
let d = s.parse::<u8>().expect("2DIGIT should match u8");
if (1..=31).contains(&d) {
Ok(d)
Expand All @@ -139,7 +139,7 @@ const TIME_DELIM: (u8, u8, u8) = (b'T', b't', b' ');
// time-hour = 2DIGIT ; 00-23
pub(crate) fn time_hour(input: Input<'_>) -> IResult<Input<'_>, u8, ParserError<'_>> {
unsigned_digits::<2, 2>
.map_res(|s: &str| {
.try_map(|s: &str| {
let d = s.parse::<u8>().expect("2DIGIT should match u8");
if (0..=23).contains(&d) {
Ok(d)
Expand All @@ -153,7 +153,7 @@ pub(crate) fn time_hour(input: Input<'_>) -> IResult<Input<'_>, u8, ParserError<
// time-minute = 2DIGIT ; 00-59
pub(crate) fn time_minute(input: Input<'_>) -> IResult<Input<'_>, u8, ParserError<'_>> {
unsigned_digits::<2, 2>
.map_res(|s: &str| {
.try_map(|s: &str| {
let d = s.parse::<u8>().expect("2DIGIT should match u8");
if (0..=59).contains(&d) {
Ok(d)
Expand All @@ -167,7 +167,7 @@ pub(crate) fn time_minute(input: Input<'_>) -> IResult<Input<'_>, u8, ParserErro
// time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second rules
pub(crate) fn time_second(input: Input<'_>) -> IResult<Input<'_>, u8, ParserError<'_>> {
unsigned_digits::<2, 2>
.map_res(|s: &str| {
.try_map(|s: &str| {
let d = s.parse::<u8>().expect("2DIGIT should match u8");
if (0..=60).contains(&d) {
Ok(d)
Expand All @@ -194,7 +194,7 @@ pub(crate) fn time_secfrac(input: Input<'_>) -> IResult<Input<'_>, u32, ParserEr
];
const INF: usize = usize::MAX;
preceded(b'.', unsigned_digits::<1, INF>)
.map_res(|mut repr: &str| -> Result<u32, CustomError> {
.try_map(|mut repr: &str| -> Result<u32, CustomError> {
let max_digits = SCALE.len() - 1;
if max_digits < repr.len() {
// Millisecond precision is required. Further precision of fractional seconds is
Expand All @@ -217,7 +217,7 @@ pub(crate) fn time_secfrac(input: Input<'_>) -> IResult<Input<'_>, u32, ParserEr
pub(crate) fn unsigned_digits<const MIN: usize, const MAX: usize>(
input: Input<'_>,
) -> IResult<Input<'_>, &str, ParserError<'_>> {
take_while_m_n(MIN, MAX, DIGIT)
take_while(MIN..=MAX, DIGIT)
.map(|b: &[u8]| unsafe { from_utf8_unchecked(b, "`is_ascii_digit` filters out on-ASCII") })
.parse_next(input)
}
Expand Down
12 changes: 6 additions & 6 deletions crates/toml_edit/src/parser/document.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::cell::RefCell;

use winnow::bytes::any;
use winnow::bytes::one_of;
use winnow::combinator::cut_err;
use winnow::combinator::eof;
use winnow::combinator::opt;
use winnow::combinator::peek;
use winnow::combinator::repeat0;
use winnow::error::FromExternalError;
use winnow::multi::many0;
use winnow::token::any;
use winnow::token::one_of;

use crate::document::Document;
use crate::key::Key;
Expand Down Expand Up @@ -38,7 +38,7 @@ pub(crate) fn document(input: Input<'_>) -> IResult<Input<'_>, Document, ParserE
// Remove BOM if present
opt(b"\xEF\xBB\xBF"),
parse_ws(state_ref),
many0((
repeat0((
dispatch! {peek(any);
crate::parser::trivia::COMMENT_START_SYMBOL => cut_err(parse_comment(state_ref)),
crate::parser::table::STD_TABLE_OPEN => cut_err(table(state_ref)),
Expand Down Expand Up @@ -104,7 +104,7 @@ pub(crate) fn keyval<'s, 'i>(
) -> impl FnMut(Input<'i>) -> IResult<Input<'i>, (), ParserError<'i>> + 's {
move |i| {
parse_keyval
.map_res(|(p, kv)| state.borrow_mut().on_keyval(p, kv))
.try_map(|(p, kv)| state.borrow_mut().on_keyval(p, kv))
.parse_next(i)
}
}
Expand All @@ -128,7 +128,7 @@ pub(crate) fn parse_keyval(
),
)),
)
.map_res::<_, _, std::str::Utf8Error>(|(key, (_, v))| {
.try_map::<_, _, std::str::Utf8Error>(|(key, (_, v))| {
let mut path = key;
let key = path.pop().expect("grammar ensures at least 1");

Expand Down
8 changes: 4 additions & 4 deletions crates/toml_edit/src/parser/inline_table.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use winnow::bytes::one_of;
use winnow::combinator::cut_err;
use winnow::multi::separated0;
use winnow::sequence::delimited;
use winnow::combinator::delimited;
use winnow::combinator::separated0;
use winnow::token::one_of;

use crate::key::Key;
use crate::parser::errors::CustomError;
Expand All @@ -23,7 +23,7 @@ pub(crate) fn inline_table(
move |input| {
delimited(
INLINE_TABLE_OPEN,
cut_err(inline_table_keyvals(check).map_res(|(kv, p)| table_from_pairs(kv, p))),
cut_err(inline_table_keyvals(check).try_map(|(kv, p)| table_from_pairs(kv, p))),
cut_err(INLINE_TABLE_CLOSE)
.context(Context::Expression("inline table"))
.context(Context::Expected(ParserValue::CharLiteral('}'))),
Expand Down
8 changes: 4 additions & 4 deletions crates/toml_edit/src/parser/key.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::ops::RangeInclusive;

use winnow::bytes::any;
use winnow::bytes::take_while1;
use winnow::combinator::peek;
use winnow::multi::separated1;
use winnow::combinator::separated1;
use winnow::token::any;
use winnow::token::take_while1;

use crate::key::Key;
use crate::parser::errors::CustomError;
Expand All @@ -29,7 +29,7 @@ pub(crate) fn key(input: Input<'_>) -> IResult<Input<'_>, Vec<Key>, ParserError<
DOT_SEP,
)
.context(Context::Expression("key"))
.map_res(|k: Vec<_>| {
.try_map(|k: Vec<_>| {
// Inserting the key will require recursion down the line
RecursionCheck::check_depth(k.len())?;
Ok::<_, CustomError>(k)
Expand Down
32 changes: 16 additions & 16 deletions crates/toml_edit/src/parser/numbers.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use std::ops::RangeInclusive;

use winnow::branch::alt;
use winnow::bytes::one_of;
use winnow::bytes::tag;
use winnow::bytes::take;
use winnow::combinator::alt;
use winnow::combinator::cut_err;
use winnow::combinator::opt;
use winnow::combinator::peek;
use winnow::combinator::preceded;
use winnow::combinator::repeat0;
use winnow::combinator::rest;
use winnow::multi::many0;
use winnow::sequence::preceded;
use winnow::token::one_of;
use winnow::token::tag;
use winnow::token::take;

use crate::parser::prelude::*;
use crate::parser::trivia::from_utf8_unchecked;
Expand Down Expand Up @@ -39,11 +39,11 @@ const FALSE: &[u8] = b"false";
// integer = dec-int / hex-int / oct-int / bin-int
pub(crate) fn integer(input: Input<'_>) -> IResult<Input<'_>, i64, ParserError<'_>> {
dispatch! {peek(opt::<_, &[u8], _, _>(take(2usize)));
Some(b"0x") => cut_err(hex_int.map_res(|s| i64::from_str_radix(&s.replace('_', ""), 16))),
Some(b"0o") => cut_err(oct_int.map_res(|s| i64::from_str_radix(&s.replace('_', ""), 8))),
Some(b"0b") => cut_err(bin_int.map_res(|s| i64::from_str_radix(&s.replace('_', ""), 2))),
Some(b"0x") => cut_err(hex_int.try_map(|s| i64::from_str_radix(&s.replace('_', ""), 16))),
Some(b"0o") => cut_err(oct_int.try_map(|s| i64::from_str_radix(&s.replace('_', ""), 8))),
Some(b"0b") => cut_err(bin_int.try_map(|s| i64::from_str_radix(&s.replace('_', ""), 2))),
_ => dec_int.and_then(cut_err(rest
.map_res(|s: &str| s.replace('_', "").parse())))
.try_map(|s: &str| s.replace('_', "").parse())))
}
.parse_next(input)
}
Expand All @@ -56,7 +56,7 @@ pub(crate) fn dec_int(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<
alt((
(
one_of(DIGIT1_9),
many0(alt((
repeat0(alt((
digit.value(()),
(
one_of(b'_'),
Expand Down Expand Up @@ -85,7 +85,7 @@ pub(crate) fn hex_int(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<
HEX_PREFIX,
cut_err((
hexdig,
many0(alt((
repeat0(alt((
hexdig.value(()),
(
one_of(b'_'),
Expand All @@ -110,7 +110,7 @@ pub(crate) fn oct_int(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<
OCT_PREFIX,
cut_err((
one_of(DIGIT0_7),
many0(alt((
repeat0(alt((
one_of(DIGIT0_7).value(()),
(
one_of(b'_'),
Expand All @@ -137,7 +137,7 @@ pub(crate) fn bin_int(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<
BIN_PREFIX,
cut_err((
one_of(DIGIT0_1),
many0(alt((
repeat0(alt((
one_of(DIGIT0_1).value(()),
(
one_of(b'_'),
Expand Down Expand Up @@ -165,7 +165,7 @@ const DIGIT0_1: RangeInclusive<u8> = b'0'..=b'1';
pub(crate) fn float(input: Input<'_>) -> IResult<Input<'_>, f64, ParserError<'_>> {
alt((
float_.and_then(cut_err(
rest.map_res(|s: &str| s.replace('_', "").parse())
rest.try_map(|s: &str| s.replace('_', "").parse())
.verify(|f: &f64| *f != f64::INFINITY),
)),
special_float,
Expand Down Expand Up @@ -207,7 +207,7 @@ pub(crate) fn frac(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<'_>
pub(crate) fn zero_prefixable_int(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<'_>> {
(
digit,
many0(alt((
repeat0(alt((
digit.value(()),
(
one_of(b'_'),
Expand Down

0 comments on commit b1430ac

Please sign in to comment.