diff --git a/Cargo.lock b/Cargo.lock index 7374554..1914fdc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1451,7 +1451,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.26", ] [[package]] @@ -1508,7 +1508,7 @@ dependencies = [ "simdutf8", "snapbox", "unicode-xid", - "winnow", + "winnow 0.7.0", ] [[package]] @@ -1702,7 +1702,7 @@ version = "5.0.1" dependencies = [ "enumflags2", "snapbox", - "winnow", + "winnow 0.7.0", ] [[package]] @@ -1917,9 +1917,18 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.21" +version = "0.6.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68" +checksum = "1e90edd2ac1aa278a5c4599b1d89cf03074b610800f866d4026dc199d7929a28" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" dependencies = [ "memchr", ] diff --git a/crates/typos/Cargo.toml b/crates/typos/Cargo.toml index 727fb54..7e8871c 100644 --- a/crates/typos/Cargo.toml +++ b/crates/typos/Cargo.toml @@ -16,7 +16,7 @@ all-features = true rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] [dependencies] -winnow = "0.6.7" +winnow = "0.7.0" unicode-xid = "0.2.4" serde = { version = "1.0", features = ["derive"] } simdutf8 = "0.1.4" diff --git a/crates/typos/src/tokens.rs b/crates/typos/src/tokens.rs index fc3f42b..e715bf9 100644 --- a/crates/typos/src/tokens.rs +++ b/crates/typos/src/tokens.rs @@ -140,12 +140,13 @@ mod parser { use winnow::stream::Stream; use winnow::stream::StreamIsPartial; use winnow::token::{one_of, take_while}; + use winnow::Result; /// Avoid worst-case parse times by limiting how much a `take_while` can take if something /// later may cause it to fail. const NON_TERMINATING_CAP: usize = 1024; - pub(crate) fn next_identifier(input: &mut T) -> PResult<::Slice, ()> + pub(crate) fn next_identifier(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -155,7 +156,7 @@ mod parser { preceded(ignore, identifier).parse_next(input) } - fn identifier(input: &mut T) -> PResult<::Slice, ()> + fn identifier(input: &mut T) -> Result<::Slice, ()> where T: Stream + StreamIsPartial + PartialEq, ::Slice: AsBStr + SliceLen + Default, @@ -173,7 +174,7 @@ mod parser { .parse_next(input) } - fn ignore(input: &mut T) -> PResult<::Slice, ()> + fn ignore(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -204,7 +205,7 @@ mod parser { .parse_next(input) } - fn sep1(input: &mut T) -> PResult<::Slice, ()> + fn sep1(input: &mut T) -> Result<::Slice, ()> where T: Stream + StreamIsPartial + PartialEq, ::Slice: AsBStr + SliceLen + Default, @@ -217,7 +218,7 @@ mod parser { .parse_next(input) } - fn other(input: &mut T) -> PResult<::Slice, ()> + fn other(input: &mut T) -> Result<::Slice, ()> where T: Stream + StreamIsPartial + PartialEq, ::Slice: AsBStr + SliceLen + Default, @@ -234,7 +235,7 @@ mod parser { .parse_next(input) } - fn ordinal_literal(input: &mut T) -> PResult<::Slice, ()> + fn ordinal_literal(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -260,7 +261,7 @@ mod parser { .parse_next(input) } - fn dec_literal(input: &mut T) -> PResult<::Slice, ()> + fn dec_literal(input: &mut T) -> Result<::Slice, ()> where T: Stream + StreamIsPartial + PartialEq, ::Slice: AsBStr + SliceLen + Default, @@ -269,7 +270,7 @@ mod parser { trace("dec_literal", take_while(1.., is_dec_digit_with_sep)).parse_next(input) } - fn hex_literal(input: &mut T) -> PResult<::Slice, ()> + fn hex_literal(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -281,7 +282,7 @@ mod parser { .parse_next(input) } - fn css_color(input: &mut T) -> PResult<::Slice, ()> + fn css_color(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -302,7 +303,7 @@ mod parser { .parse_next(input) } - fn jwt(input: &mut T) -> PResult<::Slice, ()> + fn jwt(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -337,7 +338,7 @@ mod parser { || c == '-' } - fn uuid_literal(input: &mut T) -> PResult<::Slice, ()> + fn uuid_literal(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -375,7 +376,7 @@ mod parser { .parse_next(input) } - fn hash_literal(input: &mut T) -> PResult<::Slice, ()> + fn hash_literal(input: &mut T) -> Result<::Slice, ()> where T: Stream + StreamIsPartial + PartialEq, ::Slice: AsBStr + SliceLen + Default, @@ -401,7 +402,7 @@ mod parser { .parse_next(input) } - fn base64_literal(input: &mut T) -> PResult<::Slice, ()> + fn base64_literal(input: &mut T) -> Result<::Slice, ()> where T: Stream + StreamIsPartial + PartialEq, ::Slice: AsBStr + SliceLen + Default, @@ -425,10 +426,8 @@ mod parser { .iter() .all(|c| !['/', '+'].contains(&c.as_char())) { - return Err(winnow::error::ErrMode::from_error_kind( - input, - winnow::error::ErrorKind::Slice, - )); + #[allow(clippy::unit_arg)] + return Err(ParserError::from_input(input)); } take_while(padding_len..=padding_len, is_base64_padding).parse_next(input)?; @@ -440,7 +439,7 @@ mod parser { .parse_next(input) } - fn email_literal(input: &mut T) -> PResult<::Slice, ()> + fn email_literal(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -459,7 +458,7 @@ mod parser { .parse_next(input) } - fn url_literal(input: &mut T) -> PResult<::Slice, ()> + fn url_literal(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -492,7 +491,7 @@ mod parser { .parse_next(input) } - fn url_userinfo(input: &mut T) -> PResult<::Slice, ()> + fn url_userinfo(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, @@ -510,7 +509,7 @@ mod parser { .parse_next(input) } - fn c_escape(input: &mut T) -> PResult<::Slice, ()> + fn c_escape(input: &mut T) -> Result<::Slice, ()> where T: Stream + StreamIsPartial + PartialEq, ::Slice: AsBStr + SliceLen + Default, @@ -531,7 +530,7 @@ mod parser { .parse_next(input) } - fn printf(input: &mut T) -> PResult<::Slice, ()> + fn printf(input: &mut T) -> Result<::Slice, ()> where T: Compare, T: Stream + StreamIsPartial + PartialEq, diff --git a/crates/varcon-core/Cargo.toml b/crates/varcon-core/Cargo.toml index a345878..edcfeb2 100644 --- a/crates/varcon-core/Cargo.toml +++ b/crates/varcon-core/Cargo.toml @@ -20,7 +20,7 @@ parser = ["dep:winnow"] flags = ["dep:enumflags2"] [dependencies] -winnow = { version = "0.6.7", optional = true } +winnow = { version = "0.7.0", optional = true } enumflags2 = { version = "0.7", optional = true } [lints] diff --git a/crates/varcon-core/src/parser.rs b/crates/varcon-core/src/parser.rs index adc6bea..8da9b7b 100644 --- a/crates/varcon-core/src/parser.rs +++ b/crates/varcon-core/src/parser.rs @@ -546,7 +546,7 @@ impl Cluster { Self::parse_.parse(input).map_err(|_err| ParseError) } - fn parse_(input: &mut &str) -> PResult { + fn parse_(input: &mut &str) -> ModalResult { trace("cluster", move |input: &mut &str| { let header = ( "#", @@ -966,7 +966,7 @@ impl Entry { Self::parse_.parse(input).map_err(|_err| ParseError) } - fn parse_(input: &mut &str) -> PResult { + fn parse_(input: &mut &str) -> ModalResult { trace("entry", move |input: &mut &str| { let var_sep = (winnow::ascii::space0, '/', winnow::ascii::space0); let variants = @@ -987,7 +987,7 @@ impl Entry { .parse_next(input) } - fn parse_description(input: &mut &str) -> PResult { + fn parse_description(input: &mut &str) -> ModalResult { trace("description", move |input: &mut &str| { let mut entry = Self { variants: Vec::new(), @@ -1023,18 +1023,18 @@ impl Entry { } } -fn note(input: &mut &str) -> PResult { +fn note(input: &mut &str) -> ModalResult { let (_, _, note) = (NOTE_PREFIX, space1, description).parse_next(input)?; Ok(note) } const NOTE_PREFIX: &str = "--"; -fn archaic(input: &mut &str) -> PResult<(), ()> { +fn archaic(input: &mut &str) -> ModalResult<(), ()> { "(-)".void().parse_next(input) } -fn description(input: &mut &str) -> PResult { +fn description(input: &mut &str) -> ModalResult { let description = winnow::token::take_till(0.., ('\n', '\r', '#', '|')).parse_next(input)?; Ok(description.to_owned()) } @@ -1573,7 +1573,7 @@ impl Variant { Self::parse_.parse(input).map_err(|_err| ParseError) } - fn parse_(input: &mut &str) -> PResult { + fn parse_(input: &mut &str) -> ModalResult { trace("variant", move |input: &mut &str| { let types = winnow::combinator::separated(1.., Type::parse_, space1); let columns = @@ -1592,7 +1592,7 @@ impl Variant { } } -fn word(input: &mut &str) -> PResult { +fn word(input: &mut &str) -> ModalResult { trace("word", move |input: &mut &str| { winnow::token::take_till(1.., |item: char| item.is_ascii_whitespace()) .map(|s: &str| s.to_owned().replace('_', " ")) @@ -1734,7 +1734,7 @@ impl Type { Self::parse_.parse(input).map_err(|_err| ParseError) } - fn parse_(input: &mut &str) -> PResult { + fn parse_(input: &mut &str) -> ModalResult { trace("type", move |input: &mut &str| { let category = Category::parse_(input)?; let tag = opt(Tag::parse_).parse_next(input)?; @@ -1850,7 +1850,7 @@ impl Category { Self::parse_.parse(input).map_err(|_err| ParseError) } - fn parse_(input: &mut &str) -> PResult { + fn parse_(input: &mut &str) -> ModalResult { trace("category", move |input: &mut &str| { let symbols = one_of(['A', 'B', 'Z', 'C', 'D', '_']); symbols @@ -1909,7 +1909,7 @@ impl Tag { Self::parse_.parse(input).map_err(|_err| ParseError) } - fn parse_(input: &mut &str) -> PResult { + fn parse_(input: &mut &str) -> ModalResult { trace("tag", move |input: &mut &str| { let symbols = one_of(['.', 'v', 'V', '-', 'x']); symbols @@ -1967,7 +1967,7 @@ impl Pos { Self::parse_.parse(input).map_err(|_err| ParseError) } - fn parse_(input: &mut &str) -> PResult { + fn parse_(input: &mut &str) -> ModalResult { trace("pos", move |input: &mut &str| { alt(( "N".value(Pos::Noun),