You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2024/02/26 11:27:19 UTC
(avro) branch main updated: NO-JIRA: [Rust] Fix build errors with 1.78.0-nightly (0ecbd0605 2024-02-25)
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/main by this push:
new 9e72af259 NO-JIRA: [Rust] Fix build errors with 1.78.0-nightly (0ecbd0605 2024-02-25)
9e72af259 is described below
commit 9e72af2593ceb76ccde7710408f1177635697ece
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Mon Feb 26 13:24:43 2024 +0200
NO-JIRA: [Rust] Fix build errors with 1.78.0-nightly (0ecbd0605 2024-02-25)
Extract the test trait impls out of the test function body.
No user facing changes!
```
error: non-local `impl` definition, they should be avoided as they go against expectation
--> avro/tests/validators.rs:42:5
|
42 | / impl SchemaNamespaceValidator for CustomValidator {
43 | | fn validate(&self, _ns: &str) -> AvroResult<()> {
44 | | Ok(())
45 | | }
46 | | }
| |_____^
|
= help: move this `impl` block outside the of the current function `avro_3900_custom_validator_with_spec_invalid_names`
= note: an `impl` definition is non-local if it is nested inside an item and neither the type nor the trait are at the same nesting level as the `impl` block
= note: one exception to the rule are anon-const (`const _: () = { ... }`) at top-level module and anon-const at the same nesting as the trait or type
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
```
Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
lang/rust/avro/tests/validators.rs | 42 +++++++++++++++++------------------
lang/rust/avro_test_helper/src/lib.rs | 2 +-
2 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/lang/rust/avro/tests/validators.rs b/lang/rust/avro/tests/validators.rs
index 941ffc3e7..fc45353a8 100644
--- a/lang/rust/avro/tests/validators.rs
+++ b/lang/rust/avro/tests/validators.rs
@@ -28,35 +28,35 @@ use apache_avro_test_helper::TestResult;
struct CustomValidator;
-#[test]
-fn avro_3900_custom_validator_with_spec_invalid_names() -> TestResult {
- // Setup the custom validators before the schema is parsed
- // because the parsing will trigger the validation and will
- // setup the default validator (SpecificationValidator)!
- impl SchemaNameValidator for CustomValidator {
- fn validate(&self, schema_name: &str) -> AvroResult<(String, Namespace)> {
- Ok((schema_name.to_string(), None))
- }
+// Setup the custom validators before the schema is parsed
+// because the parsing will trigger the validation and will
+// setup the default validator (SpecificationValidator)!
+impl SchemaNameValidator for CustomValidator {
+ fn validate(&self, schema_name: &str) -> AvroResult<(String, Namespace)> {
+ Ok((schema_name.to_string(), None))
}
+}
- impl SchemaNamespaceValidator for CustomValidator {
- fn validate(&self, _ns: &str) -> AvroResult<()> {
- Ok(())
- }
+impl SchemaNamespaceValidator for CustomValidator {
+ fn validate(&self, _ns: &str) -> AvroResult<()> {
+ Ok(())
}
+}
- impl EnumSymbolNameValidator for CustomValidator {
- fn validate(&self, _ns: &str) -> AvroResult<()> {
- Ok(())
- }
+impl EnumSymbolNameValidator for CustomValidator {
+ fn validate(&self, _ns: &str) -> AvroResult<()> {
+ Ok(())
}
+}
- impl RecordFieldNameValidator for CustomValidator {
- fn validate(&self, _ns: &str) -> AvroResult<()> {
- Ok(())
- }
+impl RecordFieldNameValidator for CustomValidator {
+ fn validate(&self, _ns: &str) -> AvroResult<()> {
+ Ok(())
}
+}
+#[test]
+fn avro_3900_custom_validator_with_spec_invalid_names() -> TestResult {
assert!(set_schema_name_validator(Box::new(CustomValidator)).is_ok());
assert!(set_schema_namespace_validator(Box::new(CustomValidator)).is_ok());
assert!(set_enum_symbol_name_validator(Box::new(CustomValidator)).is_ok());
diff --git a/lang/rust/avro_test_helper/src/lib.rs b/lang/rust/avro_test_helper/src/lib.rs
index 5e1e04b50..e316dc818 100644
--- a/lang/rust/avro_test_helper/src/lib.rs
+++ b/lang/rust/avro_test_helper/src/lib.rs
@@ -23,7 +23,7 @@ thread_local! {
// The unit tests run in parallel
// We need to keep the log messages in a thread-local variable
// and clear them after assertion
- pub(crate) static LOG_MESSAGES: RefCell<Vec<String>> = RefCell::new(Vec::new());
+ pub(crate) static LOG_MESSAGES: RefCell<Vec<String>> = const { RefCell::new(Vec::new()) };
}
pub mod logger;