diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b603c5b8..d7df5ed3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,31 @@ jobs: strategy: matrix: include: - - rust: 1.79.0 # MSRV, sometimes it changes because of compiler test issues + - rust: 1.81.0 # MSRV, sometimes it changes because of compiler test issues - rust: stable + steps: + - uses: actions/checkout@v3 + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust }} + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + - name: Build System Info + run: rustc --version + - name: Tests + run: | + cargo build --no-default-features + cargo test --no-default-features + cargo build --features unic --features derive --features card + cargo test --features unic --features derive --features card + test_validator-nightly: + name: Continuous integration + runs-on: ubuntu-latest + strategy: + matrix: + include: + - rust: nightly steps: - uses: actions/checkout@v3 - name: Install Rust diff --git a/CHANGELOG.md b/CHANGELOG.md index c82be07c..a94be775 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Changelog +## 0.19 (unreleased) + +- Swap to using proc-macro-error-2 instead of proc-macro-error for Syn +- Bumped MSRV to 1.81 because of error naming changes. + ## 0.18.2 (unreleased) - Add more ValidateRegex impl diff --git a/README.md b/README.md index ced009b7..4d54dc8c 100644 --- a/README.md +++ b/README.md @@ -399,3 +399,7 @@ For example, the following attributes all work: #[validate(custom(function = "custom_fn", code = "code_str", message = "message_str"))] ``` + +## Features +`derive` - This allows for the use of the derive macro. +`derive_nightly_features` - This imports both derive as well as proc-macro-error2 nightly features. This allows proc-macro-error2 to emit extra nightly warnings. \ No newline at end of file diff --git a/validator/Cargo.toml b/validator/Cargo.toml index 95eec421..03c5cec5 100644 --- a/validator/Cargo.toml +++ b/validator/Cargo.toml @@ -27,3 +27,4 @@ indexmap = { version = "2.0.0", features = ["serde"], optional = true } card = ["card-validate"] unic = ["unic-ucd-common"] derive = ["validator_derive"] +derive_nightly_features = ["derive","validator_derive/nightly_features"] \ No newline at end of file diff --git a/validator/src/lib.rs b/validator/src/lib.rs index 6346a7c6..d456e1df 100644 --- a/validator/src/lib.rs +++ b/validator/src/lib.rs @@ -76,7 +76,7 @@ pub use validation::must_match::validate_must_match; #[cfg(feature = "unic")] pub use validation::non_control_character::ValidateNonControlCharacter; pub use validation::range::ValidateRange; -pub use validation::regex::{ValidateRegex, AsRegex}; +pub use validation::regex::{AsRegex, ValidateRegex}; pub use validation::required::ValidateRequired; pub use validation::urls::ValidateUrl; diff --git a/validator/src/validation/regex.rs b/validator/src/validation/regex.rs index 1668f081..f1ed8614 100644 --- a/validator/src/validation/regex.rs +++ b/validator/src/validation/regex.rs @@ -108,19 +108,19 @@ impl ValidateRegex for str { } } -impl ValidateRegex for Box { +impl ValidateRegex for Box { fn validate_regex(&self, regex: impl AsRegex) -> bool { self.as_ref().validate_regex(regex) } } -impl ValidateRegex for Rc { +impl ValidateRegex for Rc { fn validate_regex(&self, regex: impl AsRegex) -> bool { self.as_ref().validate_regex(regex) } } -impl ValidateRegex for Arc { +impl ValidateRegex for Arc { fn validate_regex(&self, regex: impl AsRegex) -> bool { self.as_ref().validate_regex(regex) } diff --git a/validator_derive/Cargo.toml b/validator_derive/Cargo.toml index bf46cd4a..edf08998 100644 --- a/validator_derive/Cargo.toml +++ b/validator_derive/Cargo.toml @@ -17,6 +17,9 @@ proc-macro = true syn = "2" quote = "1" proc-macro2 = "1" -proc-macro-error = "1" +proc-macro-error2 = "2" darling = { version = "0.20", features = ["suggestions"] } once_cell = "1.18.0" + +[features] +nightly_features = ["proc-macro-error2/nightly"] \ No newline at end of file diff --git a/validator_derive/src/lib.rs b/validator_derive/src/lib.rs index e707e0ef..95e85508 100644 --- a/validator_derive/src/lib.rs +++ b/validator_derive/src/lib.rs @@ -1,7 +1,7 @@ use darling::ast::Data; use darling::util::{Override, WithOriginal}; use darling::FromDeriveInput; -use proc_macro_error::{abort, proc_macro_error}; +use proc_macro_error2::{abort, proc_macro_error}; use quote::{quote, ToTokens}; use syn::{parse_macro_input, DeriveInput, Field, GenericParam, Path, PathArguments}; diff --git a/validator_derive/src/types.rs b/validator_derive/src/types.rs index c34da3d0..8832fca2 100644 --- a/validator_derive/src/types.rs +++ b/validator_derive/src/types.rs @@ -3,7 +3,7 @@ use once_cell::sync::Lazy; use darling::util::Override; use darling::{FromField, FromMeta}; -use proc_macro_error::abort; +use proc_macro_error2::abort; use quote::quote; use syn::spanned::Spanned; use syn::{Expr, Field, Ident, Path}; diff --git a/validator_derive_tests/Cargo.toml b/validator_derive_tests/Cargo.toml index b548ff59..c0e55169 100644 --- a/validator_derive_tests/Cargo.toml +++ b/validator_derive_tests/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [features] default = ["test_ui"] test_ui = [] +nightly = [] [dev-dependencies] validator = { version = "0.18", path = "../validator", features = [ diff --git a/validator_derive_tests/tests/compile-fail/wrong_crate_alias.stderr b/validator_derive_tests/tests/compile-fail/wrong_crate_alias.stderr index 69855164..7e367b79 100644 --- a/validator_derive_tests/tests/compile-fail/wrong_crate_alias.stderr +++ b/validator_derive_tests/tests/compile-fail/wrong_crate_alias.stderr @@ -10,7 +10,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `validator_ot 9 | #[validate(crate = "validator_other")] | ^^^^^^^^^^^^^^^^^ use of undeclared crate or module `validator_other` | -help: consider importing one of these items +help: consider importing one of these structs | 4 + use crate::validator_renamed::ValidationErrors; | @@ -23,7 +23,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `validator_ot 9 | #[validate(crate = "validator_other")] | ^^^^^^^^^^^^^^^^^ use of undeclared crate or module `validator_other` | -help: consider importing one of these items +help: consider importing one of these structs | 4 + use crate::validator_renamed::ValidationError; | diff --git a/validator_derive_tests/tests/compile_test.rs b/validator_derive_tests/tests/compile_test.rs index bc67e4e0..04808d2b 100644 --- a/validator_derive_tests/tests/compile_test.rs +++ b/validator_derive_tests/tests/compile_test.rs @@ -2,6 +2,7 @@ #[test] fn ui() { let t = trybuild::TestCases::new(); + #[cfg(not(feature = "nightly"))] t.compile_fail("tests/compile-fail/**/*.rs"); t.pass("tests/run-pass/**/*.rs"); }