Closed matteopolak closed 4 months ago
Is it possible to add a test?
Added (also fixed the compile error). The tests cover:
::validator::...
instead of #crate_name::...
(by the compile-fail)validator::...
instead of #crate_name::...
(by the run-pass)It doesn't cover every branch, but I checked the ones for url
, email
, length
, range
, and custom
(function)
Whoops, seems like that "private" type is now permitted on the nightly channel I was on, but not on 1.70. I shuffled it around so it could be pub
to work around the issue, and tested it on 1.70
(test + build).
It looks like ti still fails?
The fail appears to be unrelated to this commit and more related to the version of nightly
being used having changed the order of the note
diagnostics:
EXPECTED:
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
error: Invalid argument reference
= note: The lifetime `'a` is not supported.
= help: Please use the validator lifetime `'v_a`
--> tests/compile-fail/custom/different_lifetime.rs:8:22
|
8 | #[validate(context = "Arg<'a>")]
| ^^^^^^^^^
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
ACTUAL OUTPUT:
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
error: Invalid argument reference
--> tests/compile-fail/custom/different_lifetime.rs:8:22
|
8 | #[validate(context = "Arg<'a>")]
| ^^^^^^^^^
|
= note: The lifetime `'a` is not supported.
= help: Please use the validator lifetime `'v_a`
┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
Looks like it has placed them at the end instead of at the start for a lot of the expect-fail tests. It might be a good idea to pin to the last-working nightly, or maybe there's a way to specify different output for a different toolchain?
I think I should remove nightly entirely from the CI, it's always failing on there for one reason or another
Sounds like a good idea. Let me know if you need anything from me to get this merged!
Currently it's not possible to package up the
validator
crate's derives without requiring users to include the dependency locally (cluttering up their deps list if they don't actually use it).This PR adds an optional
crate
attribute that overrides all references to the crate with a new name.It also works with paths, e.g.