From 55c2df20e645d70323c8255a065aa2a711045cce Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Mon, 3 Apr 2023 09:08:56 +0200 Subject: Upgrade semver to 1.0.17 This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update rust/crates/semver For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md Test: TreeHugger Change-Id: Ib884cb11b2dcc1b06ce521fa64a31eac633a5d22 --- .cargo_vcs_info.json | 2 +- .github/workflows/ci.yml | 17 ++++++++++++++++- Android.bp | 2 +- Cargo.toml | 4 ++-- Cargo.toml.orig | 2 +- LICENSE-APACHE | 25 ------------------------- METADATA | 10 +++++----- src/error.rs | 2 ++ src/lib.rs | 2 +- src/parse.rs | 4 ++++ tests/test_autotrait.rs | 2 ++ tests/test_version.rs | 5 +---- 12 files changed, 36 insertions(+), 41 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 54870e9..f1fdee4 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "dda4b834a9c896d7e1c8d17d5e326386bb346b50" + "sha1": "1b162e8dd2283a62380c30b04cf8444c9c194d5c" }, "path_in_vcs": "" } \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bfe3a7..8acd5fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: CI on: push: pull_request: + workflow_dispatch: schedule: [cron: "40 1 * * *"] permissions: @@ -12,8 +13,13 @@ env: RUSTFLAGS: -Dwarnings jobs: + pre_ci: + uses: dtolnay/.github/.github/workflows/pre_ci.yml@master + test: name: Rust ${{matrix.rust}} + needs: pre_ci + if: needs.pre_ci.outputs.continue runs-on: ubuntu-latest strategy: fail-fast: false @@ -25,6 +31,9 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{matrix.rust}} + - name: Enable type layout randomization + run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV + if: matrix.rust == 'nightly' - run: cargo test - run: cargo check --no-default-features - run: cargo check --features serde @@ -32,6 +41,8 @@ jobs: node: name: Node + needs: pre_ci + if: needs.pre_ci.outputs.continue runs-on: ubuntu-latest timeout-minutes: 45 steps: @@ -54,6 +65,8 @@ jobs: miri: name: Miri + needs: pre_ci + if: needs.pre_ci.outputs.continue runs-on: ubuntu-latest env: MIRIFLAGS: -Zmiri-strict-provenance @@ -72,13 +85,15 @@ jobs: fuzz: name: Fuzz + needs: pre_ci + if: needs.pre_ci.outputs.continue runs-on: ubuntu-latest timeout-minutes: 45 steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@nightly - uses: dtolnay/install@cargo-fuzz - - run: cargo fuzz build -O + - run: cargo fuzz check outdated: name: Outdated diff --git a/Android.bp b/Android.bp index 500f53f..f148121 100644 --- a/Android.bp +++ b/Android.bp @@ -41,7 +41,7 @@ rust_library { name: "libsemver", crate_name: "semver", cargo_env_compat: true, - cargo_pkg_version: "1.0.16", + cargo_pkg_version: "1.0.17", srcs: ["src/lib.rs"], edition: "2018", features: [ diff --git a/Cargo.toml b/Cargo.toml index e0bfea2..e7fcfb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" rust-version = "1.31" name = "semver" -version = "1.0.16" +version = "1.0.17" authors = ["David Tolnay "] description = "Parser and evaluator for Cargo's flavor of Semantic Versioning" documentation = "https://docs.rs/semver" @@ -27,11 +27,11 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/semver" [package.metadata.docs.rs] -targets = ["x86_64-unknown-linux-gnu"] rustdoc-args = [ "--cfg", "doc_cfg", ] +targets = ["x86_64-unknown-linux-gnu"] [lib] doc-scrape-examples = false diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 307c361..30ee98e 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "semver" -version = "1.0.16" +version = "1.0.17" authors = ["David Tolnay "] categories = ["data-structures", "no-std"] description = "Parser and evaluator for Cargo's flavor of Semantic Versioning" diff --git a/LICENSE-APACHE b/LICENSE-APACHE index 16fe87b..1b5ec8b 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/METADATA b/METADATA index 886c058..642e29a 100644 --- a/METADATA +++ b/METADATA @@ -11,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/semver/semver-1.0.16.crate" + value: "https://static.crates.io/crates/semver/semver-1.0.17.crate" } - version: "1.0.16" + version: "1.0.17" license_type: NOTICE last_upgrade_date { - year: 2022 - month: 12 - day: 19 + year: 2023 + month: 4 + day: 3 } } diff --git a/src/error.rs b/src/error.rs index a514e3f..93b05ee 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,6 +2,7 @@ use crate::parse::Error; use core::fmt::{self, Debug, Display}; pub(crate) enum ErrorKind { + Empty, UnexpectedEnd(Position), UnexpectedChar(Position, char), UnexpectedCharAfter(Position, char), @@ -31,6 +32,7 @@ impl std::error::Error for Error {} impl Display for Error { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { match &self.kind { + ErrorKind::Empty => formatter.write_str("empty string, expected a semver version"), ErrorKind::UnexpectedEnd(pos) => { write!(formatter, "unexpected end of input while parsing {}", pos) } diff --git a/src/lib.rs b/src/lib.rs index 32ed96d..d6a8fe3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,7 +60,7 @@ //! //! [Specifying Dependencies]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html -#![doc(html_root_url = "https://docs.rs/semver/1.0.16")] +#![doc(html_root_url = "https://docs.rs/semver/1.0.17")] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![cfg_attr(all(not(feature = "std"), not(no_alloc_crate)), no_std)] #![cfg_attr(not(no_unsafe_op_in_unsafe_fn_lint), deny(unsafe_op_in_unsafe_fn))] diff --git a/src/parse.rs b/src/parse.rs index 6a8f6ff..e92d87a 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -26,6 +26,10 @@ impl FromStr for Version { type Err = Error; fn from_str(text: &str) -> Result { + if text.is_empty() { + return Err(Error::new(ErrorKind::Empty)); + } + let mut pos = Position::Major; let (major, text) = numeric_identifier(text, pos)?; let text = dot(text, pos)?; diff --git a/tests/test_autotrait.rs b/tests/test_autotrait.rs index af8534b..5d16689 100644 --- a/tests/test_autotrait.rs +++ b/tests/test_autotrait.rs @@ -1,3 +1,5 @@ +#![allow(clippy::extra_unused_type_parameters)] + fn assert_send_sync() {} #[test] diff --git a/tests/test_version.rs b/tests/test_version.rs index 93a528c..de3628f 100644 --- a/tests/test_version.rs +++ b/tests/test_version.rs @@ -12,10 +12,7 @@ use semver::{BuildMetadata, Prerelease, Version}; #[test] fn test_parse() { let err = version_err(""); - assert_to_string( - err, - "unexpected end of input while parsing major version number", - ); + assert_to_string(err, "empty string, expected a semver version"); let err = version_err(" "); assert_to_string( -- cgit v1.2.3