martin-g commented on code in PR #501:
URL: https://github.com/apache/avro-rs/pull/501#discussion_r2890177890
##########
avro_derive/src/lib.rs:
##########
Review Comment:
```suggestion
::std::option::Option::Some(schema_fields)
```
##########
avro_derive/src/lib.rs:
##########
Review Comment:
```suggestion
let mut schema_fields =
::std::vec::Vec::Vec::with_capacity(#minimum_fields);
```
##########
.github/workflows/test-lang-rust-ci.yml:
##########
@@ -61,6 +61,16 @@ jobs:
target: aarch64-unknown-linux-gnu
steps:
+ - uses: taiki-e/install-action@v2
+ if: matrix.rust == 'nightly'
+ with:
+ tool: cargo-expand
Review Comment:
https://docs.rs/macrotest/1.2.1/macrotest/#workflow recommends:
```
In CI, you’ll want to pin to a particular version, since [cargo expand’s
output is not stable across
versions](https://github.com/dtolnay/cargo-expand/issues/179).
```
##########
avro_derive/tests/ui/avro_rs_501_tuple_struct.rs:
##########
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use apache_avro::AvroSchema;
+
+#[derive(AvroSchema)]
+struct B (i32, String);
Review Comment:
```suggestion
struct B(i32, String);
```
##########
avro_derive/src/enums/plain.rs:
##########
@@ -46,15 +46,14 @@ pub fn schema_def(
};
symbols.push(name);
}
- let full_schema_name = &container_attrs.name;
Ok(quote! {
-
::apache_avro::schema::Schema::Enum(apache_avro::schema::EnumSchema {
- name:
::apache_avro::schema::Name::new(#full_schema_name).expect(&format!("Unable to
parse enum name for schema {}", #full_schema_name)[..]),
+
::apache_avro::schema::Schema::Enum(::apache_avro::schema::EnumSchema {
+ name,
Review Comment:
It took me a while to figure out where this `name` comes from ...
This macro-related code is ain't pretty!
##########
avro_derive/tests/expand.rs:
##########
@@ -0,0 +1,27 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// By including the (unexpanded) modules, we can also test that the
+// generated code is valid.
+mod expanded;
+
+/// These tests only run on nightly as the output can change per compiler
version.
+#[rustversion::attr(not(nightly), ignore)]
+#[test]
+pub fn expand() {
Review Comment:
```suggestion
fn expand() {
```
##########
avro_derive/tests/expand.rs:
##########
@@ -0,0 +1,27 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// By including the (unexpanded) modules, we can also test that the
+// generated code is valid.
+mod expanded;
+
+/// These tests only run on nightly as the output can change per compiler
version.
Review Comment:
```suggestion
/// These tests only run on nightly as the output can change per compiler
version.
/// Use `MACROTEST=overwrite cargo +nightly test expand` to re-generate them
```
##########
avro_derive/tests/ui/avro_rs_501_tuple_struct.stderr:
##########
@@ -0,0 +1,5 @@
+error: AvroSchema derive does not work for tuple structs
+ --> tests/ui/avro_rs_501_tuple_struct.rs:21:8
+ |
+21 | struct B (i32, String);
Review Comment:
```suggestion
21 | struct B(i32, String);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]