Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap to Proc Macro Error 2 RUSTSEC-2024-0370 #350

Merged
merged 15 commits into from
Oct 25, 2024
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions validator/src/validation/regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ impl ValidateRegex for str {
}
}

impl<T:ValidateRegex> ValidateRegex for Box<T> {
impl<T: ValidateRegex> ValidateRegex for Box<T> {
fn validate_regex(&self, regex: impl AsRegex) -> bool {
self.as_ref().validate_regex(regex)
}
}

impl<T:ValidateRegex> ValidateRegex for Rc<T> {
impl<T: ValidateRegex> ValidateRegex for Rc<T> {
fn validate_regex(&self, regex: impl AsRegex) -> bool {
self.as_ref().validate_regex(regex)
}
}

impl<T:ValidateRegex> ValidateRegex for Arc<T> {
impl<T: ValidateRegex> ValidateRegex for Arc<T> {
fn validate_regex(&self, regex: impl AsRegex) -> bool {
self.as_ref().validate_regex(regex)
}
Expand Down
5 changes: 4 additions & 1 deletion validator_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ proc-macro = true
syn = "2"
quote = "1"
proc-macro2 = "1"
proc-macro-error = "1"
proc-macro-error2 = "2"
pvichivanives marked this conversation as resolved.
Show resolved Hide resolved
darling = { version = "0.20", features = ["suggestions"] }
once_cell = "1.18.0"

[features]
nightly_features = ["proc-macro-error2/nightly"]
2 changes: 1 addition & 1 deletion validator_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
2 changes: 1 addition & 1 deletion validator_derive/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 1 addition & 0 deletions validator_derive_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
[features]
default = ["test_ui"]
test_ui = []
nightly = []

[dev-dependencies]
validator = { version = "0.18", path = "../validator", features = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
|
Expand All @@ -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;
|
Expand Down
1 change: 1 addition & 0 deletions validator_derive_tests/tests/compile_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Loading