Skip to content

Commit 9e69f00

Browse files
committed
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 <rust-lang/rust#120363> ``` Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
1 parent bb00ce2 commit 9e69f00

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

avro/tests/validators.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,35 @@ use apache_avro_test_helper::TestResult;
2828

2929
struct CustomValidator;
3030

31-
#[test]
32-
fn avro_3900_custom_validator_with_spec_invalid_names() -> TestResult {
33-
// Setup the custom validators before the schema is parsed
34-
// because the parsing will trigger the validation and will
35-
// setup the default validator (SpecificationValidator)!
36-
impl SchemaNameValidator for CustomValidator {
37-
fn validate(&self, schema_name: &str) -> AvroResult<(String, Namespace)> {
38-
Ok((schema_name.to_string(), None))
39-
}
31+
// Setup the custom validators before the schema is parsed
32+
// because the parsing will trigger the validation and will
33+
// setup the default validator (SpecificationValidator)!
34+
impl SchemaNameValidator for CustomValidator {
35+
fn validate(&self, schema_name: &str) -> AvroResult<(String, Namespace)> {
36+
Ok((schema_name.to_string(), None))
4037
}
38+
}
4139

42-
impl SchemaNamespaceValidator for CustomValidator {
43-
fn validate(&self, _ns: &str) -> AvroResult<()> {
44-
Ok(())
45-
}
40+
impl SchemaNamespaceValidator for CustomValidator {
41+
fn validate(&self, _ns: &str) -> AvroResult<()> {
42+
Ok(())
4643
}
44+
}
4745

48-
impl EnumSymbolNameValidator for CustomValidator {
49-
fn validate(&self, _ns: &str) -> AvroResult<()> {
50-
Ok(())
51-
}
46+
impl EnumSymbolNameValidator for CustomValidator {
47+
fn validate(&self, _ns: &str) -> AvroResult<()> {
48+
Ok(())
5249
}
50+
}
5351

54-
impl RecordFieldNameValidator for CustomValidator {
55-
fn validate(&self, _ns: &str) -> AvroResult<()> {
56-
Ok(())
57-
}
52+
impl RecordFieldNameValidator for CustomValidator {
53+
fn validate(&self, _ns: &str) -> AvroResult<()> {
54+
Ok(())
5855
}
56+
}
5957

58+
#[test]
59+
fn avro_3900_custom_validator_with_spec_invalid_names() -> TestResult {
6060
assert!(set_schema_name_validator(Box::new(CustomValidator)).is_ok());
6161
assert!(set_schema_namespace_validator(Box::new(CustomValidator)).is_ok());
6262
assert!(set_enum_symbol_name_validator(Box::new(CustomValidator)).is_ok());

avro_test_helper/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ thread_local! {
2323
// The unit tests run in parallel
2424
// We need to keep the log messages in a thread-local variable
2525
// and clear them after assertion
26-
pub(crate) static LOG_MESSAGES: RefCell<Vec<String>> = RefCell::new(Vec::new());
26+
pub(crate) static LOG_MESSAGES: RefCell<Vec<String>> = const { RefCell::new(Vec::new()) };
2727
}
2828

2929
pub mod logger;

0 commit comments

Comments
 (0)