diff options
Diffstat (limited to 'vendor/toml_edit/src/parser')
-rw-r--r-- | vendor/toml_edit/src/parser/array.rs | 6 | ||||
-rw-r--r-- | vendor/toml_edit/src/parser/datetime.rs | 22 | ||||
-rw-r--r-- | vendor/toml_edit/src/parser/document.rs | 12 | ||||
-rw-r--r-- | vendor/toml_edit/src/parser/inline_table.rs | 8 | ||||
-rw-r--r-- | vendor/toml_edit/src/parser/key.rs | 10 | ||||
-rw-r--r-- | vendor/toml_edit/src/parser/numbers.rs | 124 | ||||
-rw-r--r-- | vendor/toml_edit/src/parser/strings.rs | 56 | ||||
-rw-r--r-- | vendor/toml_edit/src/parser/table.rs | 8 | ||||
-rw-r--r-- | vendor/toml_edit/src/parser/trivia.rs | 46 | ||||
-rw-r--r-- | vendor/toml_edit/src/parser/value.rs | 2 |
10 files changed, 158 insertions, 136 deletions
diff --git a/vendor/toml_edit/src/parser/array.rs b/vendor/toml_edit/src/parser/array.rs index ad6687232..a99bb8241 100644 --- a/vendor/toml_edit/src/parser/array.rs +++ b/vendor/toml_edit/src/parser/array.rs @@ -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; @@ -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)); diff --git a/vendor/toml_edit/src/parser/datetime.rs b/vendor/toml_edit/src/parser/datetime.rs index 89fd483a8..122a00f5a 100644 --- a/vendor/toml_edit/src/parser/datetime.rs +++ b/vendor/toml_edit/src/parser/datetime.rs @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 @@ -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) } diff --git a/vendor/toml_edit/src/parser/document.rs b/vendor/toml_edit/src/parser/document.rs index 3ff75361c..791185b68 100644 --- a/vendor/toml_edit/src/parser/document.rs +++ b/vendor/toml_edit/src/parser/document.rs @@ -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::repeat; 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; @@ -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(( + repeat(0.., ( 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)), @@ -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) } } @@ -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"); diff --git a/vendor/toml_edit/src/parser/inline_table.rs b/vendor/toml_edit/src/parser/inline_table.rs index 7bec28723..0a75c2104 100644 --- a/vendor/toml_edit/src/parser/inline_table.rs +++ b/vendor/toml_edit/src/parser/inline_table.rs @@ -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; @@ -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('}'))), diff --git a/vendor/toml_edit/src/parser/key.rs b/vendor/toml_edit/src/parser/key.rs index c3d4e7962..eda319307 100644 --- a/vendor/toml_edit/src/parser/key.rs +++ b/vendor/toml_edit/src/parser/key.rs @@ -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_while; use crate::key::Key; use crate::parser::errors::CustomError; @@ -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) @@ -58,7 +58,7 @@ pub(crate) fn simple_key( // unquoted-key = 1*( ALPHA / DIGIT / %x2D / %x5F ) ; A-Z / a-z / 0-9 / - / _ fn unquoted_key(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<'_>> { - take_while1(UNQUOTED_CHAR) + take_while(1.., UNQUOTED_CHAR) .map(|b| unsafe { from_utf8_unchecked(b, "`is_unquoted_char` filters out on-ASCII") }) .parse_next(input) } diff --git a/vendor/toml_edit/src/parser/numbers.rs b/vendor/toml_edit/src/parser/numbers.rs index 903b5f54a..803cc9d57 100644 --- a/vendor/toml_edit/src/parser/numbers.rs +++ b/vendor/toml_edit/src/parser/numbers.rs @@ -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::repeat; 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; @@ -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) } @@ -56,15 +56,18 @@ pub(crate) fn dec_int(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError< alt(( ( one_of(DIGIT1_9), - many0(alt(( - digit.value(()), - ( - one_of(b'_'), - cut_err(digit) - .context(Context::Expected(ParserValue::Description("digit"))), - ) - .value(()), - ))) + repeat( + 0.., + alt(( + digit.value(()), + ( + one_of(b'_'), + cut_err(digit) + .context(Context::Expected(ParserValue::Description("digit"))), + ) + .value(()), + )), + ) .map(|()| ()), ) .value(()), @@ -85,14 +88,18 @@ pub(crate) fn hex_int(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError< HEX_PREFIX, cut_err(( hexdig, - many0(alt(( - hexdig.value(()), - ( - one_of(b'_'), - cut_err(hexdig).context(Context::Expected(ParserValue::Description("digit"))), - ) - .value(()), - ))) + repeat( + 0.., + alt(( + hexdig.value(()), + ( + one_of(b'_'), + cut_err(hexdig) + .context(Context::Expected(ParserValue::Description("digit"))), + ) + .value(()), + )), + ) .map(|()| ()), )) .recognize(), @@ -110,15 +117,18 @@ pub(crate) fn oct_int(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError< OCT_PREFIX, cut_err(( one_of(DIGIT0_7), - many0(alt(( - one_of(DIGIT0_7).value(()), - ( - one_of(b'_'), - cut_err(one_of(DIGIT0_7)) - .context(Context::Expected(ParserValue::Description("digit"))), - ) - .value(()), - ))) + repeat( + 0.., + alt(( + one_of(DIGIT0_7).value(()), + ( + one_of(b'_'), + cut_err(one_of(DIGIT0_7)) + .context(Context::Expected(ParserValue::Description("digit"))), + ) + .value(()), + )), + ) .map(|()| ()), )) .recognize(), @@ -137,15 +147,18 @@ pub(crate) fn bin_int(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError< BIN_PREFIX, cut_err(( one_of(DIGIT0_1), - many0(alt(( - one_of(DIGIT0_1).value(()), - ( - one_of(b'_'), - cut_err(one_of(DIGIT0_1)) - .context(Context::Expected(ParserValue::Description("digit"))), - ) - .value(()), - ))) + repeat( + 0.., + alt(( + one_of(DIGIT0_1).value(()), + ( + one_of(b'_'), + cut_err(one_of(DIGIT0_1)) + .context(Context::Expected(ParserValue::Description("digit"))), + ) + .value(()), + )), + ) .map(|()| ()), )) .recognize(), @@ -165,7 +178,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, @@ -207,14 +220,17 @@ 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(( - digit.value(()), - ( - one_of(b'_'), - cut_err(digit).context(Context::Expected(ParserValue::Description("digit"))), - ) - .value(()), - ))) + repeat( + 0.., + alt(( + digit.value(()), + ( + one_of(b'_'), + cut_err(digit).context(Context::Expected(ParserValue::Description("digit"))), + ) + .value(()), + )), + ) .map(|()| ()), ) .recognize() diff --git a/vendor/toml_edit/src/parser/strings.rs b/vendor/toml_edit/src/parser/strings.rs index 93d034c00..2ce160506 100644 --- a/vendor/toml_edit/src/parser/strings.rs +++ b/vendor/toml_edit/src/parser/strings.rs @@ -2,25 +2,22 @@ use std::borrow::Cow; use std::char; use std::ops::RangeInclusive; -use winnow::branch::alt; -use winnow::bytes::any; -use winnow::bytes::none_of; -use winnow::bytes::one_of; -use winnow::bytes::tag; -use winnow::bytes::take_while0; -use winnow::bytes::take_while1; -use winnow::bytes::take_while_m_n; +use winnow::combinator::alt; use winnow::combinator::cut_err; +use winnow::combinator::delimited; use winnow::combinator::fail; use winnow::combinator::opt; use winnow::combinator::peek; +use winnow::combinator::preceded; +use winnow::combinator::repeat; use winnow::combinator::success; -use winnow::multi::many0; -use winnow::multi::many1; +use winnow::combinator::terminated; use winnow::prelude::*; -use winnow::sequence::delimited; -use winnow::sequence::preceded; -use winnow::sequence::terminated; +use winnow::token::any; +use winnow::token::none_of; +use winnow::token::one_of; +use winnow::token::tag; +use winnow::token::take_while; use crate::parser::errors::CustomError; use crate::parser::numbers::HEXDIG; @@ -71,8 +68,8 @@ fn basic_chars(input: Input<'_>) -> IResult<Input<'_>, Cow<'_, str>, ParserError alt(( // Deviate from the official grammar by batching the unescaped chars so we build a string a // chunk at a time, rather than a `char` at a time. - take_while1(BASIC_UNESCAPED) - .map_res(std::str::from_utf8) + take_while(1.., BASIC_UNESCAPED) + .try_map(std::str::from_utf8) .map(Cow::Borrowed), escaped.map(|c| Cow::Owned(String::from(c))), )) @@ -136,11 +133,11 @@ fn escape_seq_char(input: Input<'_>) -> IResult<Input<'_>, char, ParserError<'_> pub(crate) fn hexescape<const N: usize>( input: Input<'_>, ) -> IResult<Input<'_>, char, ParserError<'_>> { - take_while_m_n(0, N, HEXDIG) + take_while(0..=N, HEXDIG) .verify(|b: &[u8]| b.len() == N) .map(|b: &[u8]| unsafe { from_utf8_unchecked(b, "`is_ascii_digit` filters out on-ASCII") }) .verify_map(|s| u32::from_str_radix(s, 16).ok()) - .map_res(|h| char::from_u32(h).ok_or(CustomError::OutOfRange)) + .try_map(|h| char::from_u32(h).ok_or(CustomError::OutOfRange)) .parse_next(input) } @@ -203,8 +200,8 @@ fn mlb_content(input: Input<'_>) -> IResult<Input<'_>, Cow<'_, str>, ParserError alt(( // Deviate from the official grammar by batching the unescaped chars so we build a string a // chunk at a time, rather than a `char` at a time. - take_while1(MLB_UNESCAPED) - .map_res(std::str::from_utf8) + take_while(1.., MLB_UNESCAPED) + .try_map(std::str::from_utf8) .map(Cow::Borrowed), // Order changed fromg grammar so `escaped` can more easily `cut_err` on bad escape sequences mlb_escaped_nl.map(|_| Cow::Borrowed("")), @@ -247,7 +244,7 @@ pub(crate) const MLB_UNESCAPED: ( // (including newlines) up to the next non-whitespace // character or closing delimiter. fn mlb_escaped_nl(input: Input<'_>) -> IResult<Input<'_>, (), ParserError<'_>> { - many1((ESCAPE, ws, ws_newlines)) + repeat(1.., (ESCAPE, ws, ws_newlines)) .map(|()| ()) .value(()) .parse_next(input) @@ -259,10 +256,10 @@ fn mlb_escaped_nl(input: Input<'_>) -> IResult<Input<'_>, (), ParserError<'_>> { pub(crate) fn literal_string(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<'_>> { delimited( APOSTROPHE, - cut_err(take_while0(LITERAL_CHAR)), + cut_err(take_while(0.., LITERAL_CHAR)), cut_err(APOSTROPHE), ) - .map_res(std::str::from_utf8) + .try_map(std::str::from_utf8) .context(Context::Expression("literal string")) .parse_next(input) } @@ -304,16 +301,19 @@ pub(crate) const ML_LITERAL_STRING_DELIM: &[u8] = b"'''"; // ml-literal-body = *mll-content *( mll-quotes 1*mll-content ) [ mll-quotes ] fn ml_literal_body(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<'_>> { ( - many0(mll_content).map(|()| ()), - many0(( - mll_quotes(none_of(APOSTROPHE).value(())), - many1(mll_content).map(|()| ()), - )) + repeat(0.., mll_content).map(|()| ()), + repeat( + 0.., + ( + mll_quotes(none_of(APOSTROPHE).value(())), + repeat(1.., mll_content).map(|()| ()), + ), + ) .map(|()| ()), opt(mll_quotes(tag(ML_LITERAL_STRING_DELIM).value(()))), ) .recognize() - .map_res(std::str::from_utf8) + .try_map(std::str::from_utf8) .parse_next(input) } diff --git a/vendor/toml_edit/src/parser/table.rs b/vendor/toml_edit/src/parser/table.rs index a6085e475..9d2675868 100644 --- a/vendor/toml_edit/src/parser/table.rs +++ b/vendor/toml_edit/src/parser/table.rs @@ -2,10 +2,10 @@ use std::cell::RefCell; #[allow(unused_imports)] use std::ops::DerefMut; -use winnow::bytes::take; use winnow::combinator::cut_err; +use winnow::combinator::delimited; use winnow::combinator::peek; -use winnow::sequence::delimited; +use winnow::token::take; // https://github.com/rust-lang/rust/issues/41358 use crate::parser::key::key; @@ -42,7 +42,7 @@ pub(crate) fn std_table<'s, 'i>( .context(Context::Expected(ParserValue::CharLiteral('\n'))) .context(Context::Expected(ParserValue::CharLiteral('#'))), ) - .map_res(|((h, span), t)| state.borrow_mut().deref_mut().on_std_header(h, t, span)) + .try_map(|((h, span), t)| state.borrow_mut().deref_mut().on_std_header(h, t, span)) .parse_next(i) } } @@ -67,7 +67,7 @@ pub(crate) fn array_table<'s, 'i>( .context(Context::Expected(ParserValue::CharLiteral('\n'))) .context(Context::Expected(ParserValue::CharLiteral('#'))), ) - .map_res(|((h, span), t)| state.borrow_mut().deref_mut().on_array_header(h, t, span)) + .try_map(|((h, span), t)| state.borrow_mut().deref_mut().on_array_header(h, t, span)) .parse_next(i) } } diff --git a/vendor/toml_edit/src/parser/trivia.rs b/vendor/toml_edit/src/parser/trivia.rs index 97ff49c73..ba47dcde6 100644 --- a/vendor/toml_edit/src/parser/trivia.rs +++ b/vendor/toml_edit/src/parser/trivia.rs @@ -1,15 +1,13 @@ use std::ops::RangeInclusive; -use winnow::branch::alt; -use winnow::bytes::one_of; -use winnow::bytes::take_while0; -use winnow::bytes::take_while1; +use winnow::combinator::alt; use winnow::combinator::eof; use winnow::combinator::opt; -use winnow::multi::many0; -use winnow::multi::many1; +use winnow::combinator::repeat; +use winnow::combinator::terminated; use winnow::prelude::*; -use winnow::sequence::terminated; +use winnow::token::one_of; +use winnow::token::take_while; use crate::parser::prelude::*; @@ -31,7 +29,7 @@ pub(crate) const WSCHAR: (u8, u8) = (b' ', b'\t'); // ws = *wschar pub(crate) fn ws(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<'_>> { - take_while0(WSCHAR) + take_while(0.., WSCHAR) .map(|b| unsafe { from_utf8_unchecked(b, "`is_wschar` filters out on-ASCII") }) .parse_next(input) } @@ -51,7 +49,7 @@ pub(crate) const COMMENT_START_SYMBOL: u8 = b'#'; // comment = comment-start-symbol *non-eol pub(crate) fn comment(input: Input<'_>) -> IResult<Input<'_>, &[u8], ParserError<'_>> { - (COMMENT_START_SYMBOL, take_while0(NON_EOL)) + (COMMENT_START_SYMBOL, take_while(0.., NON_EOL)) .recognize() .parse_next(input) } @@ -70,13 +68,14 @@ pub(crate) const CR: u8 = b'\r'; // ws-newline = *( wschar / newline ) pub(crate) fn ws_newline(input: Input<'_>) -> IResult<Input<'_>, &str, ParserError<'_>> { - many0(alt((newline.value(&b"\n"[..]), take_while1(WSCHAR)))) - .map(|()| ()) - .recognize() - .map(|b| unsafe { - from_utf8_unchecked(b, "`is_wschar` and `newline` filters out on-ASCII") - }) - .parse_next(input) + repeat( + 0.., + alt((newline.value(&b"\n"[..]), take_while(1.., WSCHAR))), + ) + .map(|()| ()) + .recognize() + .map(|b| unsafe { from_utf8_unchecked(b, "`is_wschar` and `newline` filters out on-ASCII") }) + .parse_next(input) } // ws-newlines = newline *( wschar / newline ) @@ -92,10 +91,17 @@ pub(crate) fn ws_newlines(input: Input<'_>) -> IResult<Input<'_>, &str, ParserEr // note: this rule is not present in the original grammar // ws-comment-newline = *( ws-newline-nonempty / comment ) pub(crate) fn ws_comment_newline(input: Input<'_>) -> IResult<Input<'_>, &[u8], ParserError<'_>> { - many0(alt(( - many1(alt((take_while1(WSCHAR), newline.value(&b"\n"[..])))).map(|()| ()), - comment.value(()), - ))) + repeat( + 0.., + alt(( + repeat( + 1.., + alt((take_while(1.., WSCHAR), newline.value(&b"\n"[..]))), + ) + .map(|()| ()), + comment.value(()), + )), + ) .map(|()| ()) .recognize() .parse_next(input) diff --git a/vendor/toml_edit/src/parser/value.rs b/vendor/toml_edit/src/parser/value.rs index 63a821114..19950585b 100644 --- a/vendor/toml_edit/src/parser/value.rs +++ b/vendor/toml_edit/src/parser/value.rs @@ -84,7 +84,7 @@ pub(crate) fn value( }, } .with_span() - .map_res(|(value, span)| apply_raw(value, span)) + .try_map(|(value, span)| apply_raw(value, span)) .parse_next(input) } } |