diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 05:06:29 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 05:06:29 +0000 |
commit | ada747df87b7a46894560ba93359498de74997be (patch) | |
tree | 162e164179104d293fa483b474cc9ee418e0c5d8 | |
parent | c2d1005b7138389813f80c348af877b0677653e8 (diff) | |
parent | b256f85f3e789eee6c51c59359ab8cb3e1a77c08 (diff) | |
download | combine-ada747df87b7a46894560ba93359498de74997be.tar.gz |
Snap for 10453563 from b256f85f3e789eee6c51c59359ab8cb3e1a77c08 to mainline-permission-releaseaml_per_341614000aml_per_341510010aml_per_341410020aml_per_341311000aml_per_341110020aml_per_341110010aml_per_341011100aml_per_341011020aml_per_340916010android14-mainline-permission-release
Change-Id: Ic3ad73a36afd5e2d379409fd55636ed9d5f1389f
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | .github/workflows/rust.yml | 19 | ||||
-rw-r--r-- | Android.bp | 5 | ||||
-rw-r--r-- | CHANGELOG.md | 13 | ||||
-rw-r--r-- | Cargo.lock.saved (renamed from Cargo.lock) | 6 | ||||
-rw-r--r-- | Cargo.toml | 102 | ||||
-rw-r--r-- | Cargo.toml.orig | 8 | ||||
-rw-r--r-- | METADATA | 12 | ||||
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | benches/http.rs | 2 | ||||
-rwxr-xr-x | ci.sh | 31 | ||||
-rw-r--r-- | src/parser/range.rs | 1 | ||||
-rw-r--r-- | src/parser/sequence.rs | 73 | ||||
-rw-r--r-- | src/stream/mod.rs | 12 | ||||
-rw-r--r-- | tests/async.rs | 4 |
15 files changed, 208 insertions, 92 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index bce2fd1..eacdbba 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "84ceb76d89f267dcffe2802b336f88b451cdc01f" + "sha1": "cbc33e72627eac452806240d4bdb948465a4cbe1" }, "path_in_vcs": "" }
\ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 94b0ed9..807ab87 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,7 +22,26 @@ jobs: steps: - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + override: true + - name: Build run: cargo build + + - name: Check 1.40 + if: ${{ matrix.rust == '1.40.0' }} + run: | + cargo "$@" check + cargo "$@" check --no-default-features + - name: Run tests + if: ${{ matrix.rust != '1.40.0' }} run: ./ci.sh + + - name: Check docs + if: ${{ matrix.rust == 'stable' }} + run: cargo doc @@ -20,11 +20,10 @@ license { rust_library { name: "libcombine", - // has rustc warnings host_supported: true, crate_name: "combine", cargo_env_compat: true, - cargo_pkg_version: "4.6.3", + cargo_pkg_version: "4.6.6", srcs: ["src/lib.rs"], edition: "2018", features: [ @@ -41,5 +40,7 @@ rust_library { "//apex_available:platform", "com.android.uwb", ], + product_available: true, + vendor_available: true, min_sdk_version: "29", } diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fbf5f4..a2bf60d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +<a name="v4.6.5"></a> +### v4.6.5 (2022-08-09) + +* memchr: use non deprecated feature `std` instead of `use_std` + +* refactor: Extract less-generic code from sequence's add_errors (-5%) + +<a name="v4.6.4"></a> +### v4.6.4 (2022-04-25) + + + + <a name="v4.6.3"></a> ### v4.6.3 (2022-01-12) diff --git a/Cargo.lock b/Cargo.lock.saved index cbeca87..1900e9c 100644 --- a/Cargo.lock +++ b/Cargo.lock.saved @@ -257,7 +257,7 @@ dependencies = [ [[package]] name = "combine" -version = "4.6.3" +version = "4.6.6" dependencies = [ "async-std", "bytes 0.5.6", @@ -1204,9 +1204,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.8" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd" +checksum = "64910e1b9c1901aaf5375561e35b9c057d95ff41a44ede043a03e09279eabaf1" dependencies = [ "bytes 1.1.0", "futures-core", @@ -12,18 +12,32 @@ [package] edition = "2018" name = "combine" -version = "4.6.3" +version = "4.6.6" authors = ["Markus Westerlind <marwes91@gmail.com>"] description = "Fast parser combinators on arbitrary streams with zero-copy support." documentation = "https://docs.rs/combine" readme = "README.md" -keywords = ["parser", "parsing", "combinators", "ll"] -categories = ["parsing", "no-std"] +keywords = [ + "parser", + "parsing", + "combinators", + "ll", +] +categories = [ + "parsing", + "no-std", +] license = "MIT" repository = "https://github.com/Marwes/combine" +resolver = "1" + [package.metadata.docs.rs] all-features = true -rustdoc-args = ["--cfg", "docsrs"] +rustdoc-args = [ + "--cfg", + "docsrs", +] + [profile.bench] lto = true codegen-units = 1 @@ -34,7 +48,10 @@ path = "src/lib.rs" [[example]] name = "async" -required-features = ["std", "tokio"] +required-features = [ + "std", + "tokio", +] [[example]] name = "date" @@ -50,7 +67,10 @@ name = "ini" [[test]] name = "async" -required-features = ["tokio-02", "futures-io-03"] +required-features = [ + "tokio-02", + "futures-io-03", +] [[bench]] name = "json" @@ -66,6 +86,7 @@ required-features = ["std"] name = "mp4" harness = false required-features = ["mp4"] + [dependencies.bytes] version = "1" optional = true @@ -88,7 +109,7 @@ default-features = false package = "futures-io" [dependencies.memchr] -version = "2.2" +version = "2.3" default-features = false [dependencies.pin-project-lite] @@ -119,10 +140,11 @@ default-features = false package = "tokio" [dependencies.tokio-util] -version = "0.6" +version = "0.7" features = ["codec"] optional = true default-features = false + [dev-dependencies.async-std] version = "1" @@ -146,7 +168,10 @@ version = "1.0" [dev-dependencies.partial-io] version = "0.3" -features = ["tokio", "quickcheck"] +features = [ + "tokio", + "quickcheck", +] [dev-dependencies.quick-error] version = "1.0" @@ -156,26 +181,69 @@ version = "0.6" [dev-dependencies.tokio-02-dep] version = "0.2" -features = ["fs", "io-driver", "io-util", "macros"] +features = [ + "fs", + "io-driver", + "io-util", + "macros", +] package = "tokio" [dev-dependencies.tokio-03-dep] version = "0.3" -features = ["fs", "macros", "rt-multi-thread"] +features = [ + "fs", + "macros", + "rt-multi-thread", +] package = "tokio" [dev-dependencies.tokio-dep] version = "1" -features = ["fs", "macros", "rt", "rt-multi-thread", "io-util"] +features = [ + "fs", + "macros", + "rt", + "rt-multi-thread", + "io-util", +] package = "tokio" [features] alloc = [] default = ["std"] -futures-03 = ["pin-project", "std", "futures-core-03", "futures-io-03", "pin-project-lite"] +futures-03 = [ + "pin-project", + "std", + "futures-core-03", + "futures-io-03", + "pin-project-lite", +] mp4 = [] pin-project = ["pin-project-lite"] -std = ["memchr/use_std", "bytes", "alloc"] -tokio = ["tokio-dep", "tokio-util/io", "futures-core-03", "pin-project-lite"] -tokio-02 = ["pin-project", "std", "tokio-02-dep", "futures-core-03", "pin-project-lite", "bytes_05"] -tokio-03 = ["pin-project", "std", "tokio-03-dep", "futures-core-03", "pin-project-lite"] +std = [ + "memchr/std", + "bytes", + "alloc", +] +tokio = [ + "tokio-dep", + "tokio-util/io", + "futures-core-03", + "pin-project-lite", +] +tokio-02 = [ + "pin-project", + "std", + "tokio-02-dep", + "futures-core-03", + "pin-project-lite", + "bytes_05", +] +tokio-03 = [ + "pin-project", + "std", + "tokio-03-dep", + "futures-core-03", + "pin-project-lite", +] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index ba58238..c301500 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "combine" -version = "4.6.3" +version = "4.6.6" authors = ["Markus Westerlind <marwes91@gmail.com>"] description = "Fast parser combinators on arbitrary streams with zero-copy support." @@ -28,13 +28,13 @@ path = "src/lib.rs" [dependencies] regex = { version = "1", optional = true } -memchr = { version = "2.2", default-features = false } +memchr = { version = "2.3", default-features = false } pin-project-lite = { version = "0.2", optional = true } # Future proofing so that tokio-0.3, tokio-0.1 etc can be supported tokio-02-dep = { version = "0.2.3", package = "tokio", features = ["io-util"], default-features = false, optional = true } tokio-03-dep = { version = "0.3", package = "tokio", default-features = false, optional = true } tokio-dep = { version = "1", package = "tokio", default-features = false, optional = true } -tokio-util = { version = "0.6", features = ["codec"], default-features = false, optional = true } +tokio-util = { version = "0.7", features = ["codec"], default-features = false, optional = true } futures-core-03 = { version = "0.3.1", package = "futures-core", default-features = false, optional = true } futures-io-03 = { version = "0.3.1", package = "futures-io", default-features = false, optional = true } bytes_05 = { version = "0.5", package = "bytes", optional = true } @@ -64,7 +64,7 @@ tokio-02 = ["pin-project", "std", "tokio-02-dep", "futures-core-03", "pin-projec tokio-03 = ["pin-project", "std", "tokio-03-dep", "futures-core-03", "pin-project-lite"] tokio = ["tokio-dep", "tokio-util/io", "futures-core-03", "pin-project-lite"] futures-03 = ["pin-project", "std", "futures-core-03", "futures-io-03", "pin-project-lite"] -std = ["memchr/use_std", "bytes", "alloc"] +std = ["memchr/std", "bytes", "alloc"] alloc = [] [[test]] @@ -1,3 +1,7 @@ +# This project was upgraded with external_updater. +# Usage: tools/external_updater/updater.sh update rust/crates/combine +# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md + name: "combine" description: "Fast parser combinators on arbitrary streams with zero-copy support." third_party { @@ -7,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/combine/combine-4.6.3.crate" + value: "https://static.crates.io/crates/combine/combine-4.6.6.crate" } - version: "4.6.3" + version: "4.6.6" license_type: NOTICE last_upgrade_date { year: 2022 - month: 3 - day: 1 + month: 12 + day: 8 } } @@ -26,14 +26,20 @@ let result = parser.parse("Pick up that word!"); assert_eq!(result, Ok((Some("word".to_string()), "!"))); ``` -A tutorial as well as explanations on what goes on inside combine can be found in [the wiki](https://github.com/Marwes/combine/wiki). - Larger examples can be found in the [examples][], [tests][] and [benches][] folders. [examples]:https://github.com/Marwes/combine/tree/master/examples [tests]:https://github.com/Marwes/combine/tree/master/tests [benches]:https://github.com/Marwes/combine/tree/master/benches +## Tutorial + +A tutorial as well as explanations on what goes on inside combine can be found in [the wiki](https://github.com/Marwes/combine/wiki). + +### Translation + +[Japanese](https://github.com/sadnessOjisan/combine-ja) + ## Links [Documentation and examples](https://docs.rs/crate/combine) diff --git a/benches/http.rs b/benches/http.rs index 68414a5..e08e973 100644 --- a/benches/http.rs +++ b/benches/http.rs @@ -17,6 +17,7 @@ use { criterion::{black_box, Bencher, Criterion}, }; +#[allow(dead_code)] #[derive(Debug)] struct Request<'a> { method: &'a [u8], @@ -24,6 +25,7 @@ struct Request<'a> { version: &'a [u8], } +#[allow(dead_code)] #[derive(Debug)] struct Header<'a> { name: &'a [u8], @@ -1,27 +1,18 @@ #!/bin/bash -x set -ex -if [[ "$TRAVIS_RUST_VERSION" == "1.40.0" ]]; then - cargo "$@" check - cargo "$@" check --no-default-features -else - cargo "$@" build - cargo "$@" test --all-features - cargo "$@" test --all-features --examples +cargo "$@" build +cargo "$@" test --all-features +cargo "$@" test --all-features --examples - cargo "$@" test --bench json --bench http -- --test - cargo "$@" check --bench mp4 --features mp4 - - cargo "$@" build --no-default-features --features alloc - cargo "$@" test --no-default-features --features alloc --examples +cargo "$@" test --bench json --bench http -- --test +cargo "$@" check --bench mp4 --features mp4 - cargo "$@" build --no-default-features - cargo "$@" test --no-default-features --examples +cargo "$@" build --no-default-features --features alloc +cargo "$@" test --no-default-features --features alloc --examples - cargo "$@" check --no-default-features --features tokio-02 - cargo "$@" check --no-default-features --features tokio-03 -fi +cargo "$@" build --no-default-features +cargo "$@" test --no-default-features --examples -if [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then - cargo doc -fi +cargo "$@" check --no-default-features --features tokio-02 +cargo "$@" check --no-default-features --features tokio-03 diff --git a/src/parser/range.rs b/src/parser/range.rs index 7b53fe6..46353eb 100644 --- a/src/parser/range.rs +++ b/src/parser/range.rs @@ -85,7 +85,6 @@ parser! { /// assert!(parser.parse("!").is_err()); /// # } /// ``` - #[inline] pub fn recognize[Input, P](parser: P)(Input) -> <Input as StreamOnce>::Range where [ P: Parser<Input>, diff --git a/src/parser/sequence.rs b/src/parser/sequence.rs index 1c8bdcb..166b89d 100644 --- a/src/parser/sequence.rs +++ b/src/parser/sequence.rs @@ -14,17 +14,6 @@ use crate::{ ErrorOffset, Parser, Stream, StreamOnce, }; -macro_rules! dispatch_on { - ($i: expr, $f: expr;) => { - }; - ($i: expr, $f: expr; $first: ident $(, $id: ident)*) => { { - let b = $f($i, $first); - if b { - dispatch_on!($i + 1, $f; $($id),*); - } - } } -} - macro_rules! count { () => { 0 }; ($f: ident) => { 1 }; @@ -63,6 +52,37 @@ macro_rules! last_ident { ($id: ident, $($rest: ident),+) => { last_ident!($($rest),+) }; } +fn add_sequence_error<Input>( + i: &mut usize, + first_empty_parser: usize, + inner_offset: ErrorOffset, + err: &mut Tracked<Input::Error>, + parser: &mut impl Parser<Input>, +) -> bool +where + Input: Stream, +{ + if *i + 1 == first_empty_parser { + Parser::add_committed_expected_error(parser, err); + } + if *i >= first_empty_parser { + if err.offset <= ErrorOffset(1) { + // We reached the last parser we need to add errors to (and the + // parser that actually returned the error), use the returned + // offset for that parser. + err.offset = inner_offset; + } + Parser::add_error(parser, err); + if err.offset <= ErrorOffset(1) { + return false; + } + } + err.offset = ErrorOffset(err.offset.0.saturating_sub(Parser::parser_count(parser).0)); + + *i += 1; + true +} + macro_rules! tuple_parser { ($partial_state: ident; $h: ident $(, $id: ident)*) => { #[allow(non_snake_case)] @@ -99,27 +119,20 @@ macro_rules! tuple_parser { if let Ok(t) = input.uncons() { err.error.add(StreamError::unexpected_token(t)); } - dispatch_on!(0, |i, mut p| { - if i + 1 == first_empty_parser { - Parser::add_committed_expected_error(&mut p, &mut err); + + #[allow(unused_assignments)] + let mut i = 0; + loop { + if !add_sequence_error(&mut i, first_empty_parser, inner_offset, &mut err, $h) { + break; } - if i >= first_empty_parser { - if err.offset <= ErrorOffset(1) { - // We reached the last parser we need to add errors to (and the - // parser that actually returned the error), use the returned - // offset for that parser. - err.offset = inner_offset; - } - Parser::add_error(&mut p, &mut err); - if err.offset <= ErrorOffset(1) { - return false; - } + $( + if !add_sequence_error(&mut i, first_empty_parser, inner_offset, &mut err, $id) { + break; } - err.offset = ErrorOffset( - err.offset.0.saturating_sub(Parser::parser_count(&p).0) - ); - true - }; $h $(, $id)*); + )* + break; + } CommitErr(err.error) } else { PeekErr(err) diff --git a/src/stream/mod.rs b/src/stream/mod.rs index 803e9a8..b1f3d07 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -53,7 +53,7 @@ pub mod buf_reader; /// Stream wrapper which provides a `ResetStream` impl for `StreamOnce` impls which do not have /// one. #[cfg(feature = "alloc")] -#[cfg_attr(docsrs, doc(cfg(feature = "std")))] +#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))] pub mod buffered; #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] @@ -1401,7 +1401,7 @@ where /// }, /// |input, _position| combine::easy::Stream::from(input), /// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from), -/// Ok(819), +/// Ok(824), /// ); /// ``` #[cfg(feature = "std")] @@ -1497,7 +1497,7 @@ macro_rules! decode { /// }, /// |input, _position| combine::easy::Stream::from(input), /// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from), -/// Ok(819), +/// Ok(824), /// ); /// } /// ``` @@ -1591,7 +1591,7 @@ macro_rules! decode_futures_03 { /// }, /// |input, _position| combine::easy::Stream::from(input), /// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from), -/// Ok(819), +/// Ok(824), /// ); /// } /// ``` @@ -1687,7 +1687,7 @@ macro_rules! decode_tokio_02 { /// }, /// |input, _position| combine::easy::Stream::from(input), /// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from), -/// Ok(819), +/// Ok(824), /// ); /// } /// ``` @@ -1783,7 +1783,7 @@ macro_rules! decode_tokio_03 { /// }, /// |input, _position| combine::easy::Stream::from(input), /// ).map_err(combine::easy::Errors::<u8, &[u8], _>::from), -/// Ok(819), +/// Ok(824), /// ); /// } /// ``` diff --git a/tests/async.rs b/tests/async.rs index f5fb063..bedaa72 100644 --- a/tests/async.rs +++ b/tests/async.rs @@ -634,7 +634,7 @@ fn skip_count_min_max_test() { assert_eq!(result.unwrap(), [""]); } -const WORDS_IN_README: usize = 819; +const WORDS_IN_README: usize = 824; #[test] fn decode_std() { @@ -850,5 +850,5 @@ async fn decode_loop() { } } } - assert_eq!(819, count); + assert_eq!(824, count); } |