This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch branch-1.11
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/branch-1.11 by this push:
     new 93efd8fff [AVRO-3708]: [Rust] Fix clippy warnings introduced with Rust 
1.67.0 (#2065)
93efd8fff is described below

commit 93efd8fff0b8db2ad35197f3fa0f443f84bd2645
Author: Martin Grigorov <[email protected]>
AuthorDate: Fri Jan 27 10:14:35 2023 +0200

    [AVRO-3708]: [Rust] Fix clippy warnings introduced with Rust 1.67.0 (#2065)
    
    Update "edition" to 2021
    Add "rust-version" with value "1.60.0"
    
    Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
    (cherry picked from commit 1580b17ca55669e9560f6d26671bee8d79701ff8)
---
 lang/rust/avro/Cargo.toml                          |  3 +-
 lang/rust/avro/examples/benchmark.rs               |  9 ++--
 lang/rust/avro/examples/generate_interop_data.rs   |  6 +--
 .../test_interop_single_object_encoding.rs         |  4 +-
 lang/rust/avro/examples/to_value.rs                |  2 +-
 lang/rust/avro/src/de.rs                           |  3 +-
 lang/rust/avro/src/encode.rs                       |  4 +-
 lang/rust/avro/src/reader.rs                       | 11 ++--
 lang/rust/avro/src/schema.rs                       | 42 ++++++---------
 lang/rust/avro/src/schema_compatibility.rs         |  2 +-
 lang/rust/avro/src/types.rs                        | 60 +++++++++-------------
 lang/rust/avro/src/writer.rs                       | 10 ++--
 lang/rust/avro/tests/append_to_existing.rs         |  4 +-
 lang/rust/avro/tests/io.rs                         | 16 ++----
 lang/rust/avro/tests/schema.rs                     | 20 +++-----
 lang/rust/avro_derive/Cargo.toml                   |  3 +-
 lang/rust/avro_derive/src/lib.rs                   | 30 ++++-------
 lang/rust/avro_derive/tests/derive.rs              | 12 ++---
 lang/rust/avro_test_helper/Cargo.toml              |  3 +-
 lang/rust/avro_test_helper/src/logger.rs           |  9 ++--
 lang/rust/fuzz/Cargo.toml                          |  3 +-
 lang/rust/wasm-demo/Cargo.toml                     |  3 +-
 22 files changed, 105 insertions(+), 154 deletions(-)

diff --git a/lang/rust/avro/Cargo.toml b/lang/rust/avro/Cargo.toml
index a046b2477..1f61762c2 100644
--- a/lang/rust/avro/Cargo.toml
+++ b/lang/rust/avro/Cargo.toml
@@ -23,7 +23,8 @@ description = "A library for working with Apache Avro in Rust"
 license = "Apache-2.0"
 readme = "README.md"
 repository = "https://github.com/apache/avro";
-edition = "2018"
+edition = "2021"
+rust-version = "1.60.0"
 keywords = ["avro", "data", "serialization"]
 categories = ["encoding"]
 documentation = "https://docs.rs/apache-avro";
diff --git a/lang/rust/avro/examples/benchmark.rs 
b/lang/rust/avro/examples/benchmark.rs
index 1829d2171..4cf0f1365 100644
--- a/lang/rust/avro/examples/benchmark.rs
+++ b/lang/rust/avro/examples/benchmark.rs
@@ -96,10 +96,7 @@ fn benchmark(
     let (total_write_secs, total_read_secs) =
         (seconds(total_duration_write), seconds(total_duration_read));
 
-    println!(
-        "{}\t\t{}\t\t{}\t\t{}\t\t{}",
-        count, runs, big_or_small, total_write_secs, total_read_secs
-    );
+    
println!("{count}\t\t{runs}\t\t{big_or_small}\t\t{total_write_secs}\t\t{total_read_secs}");
     Ok(())
 }
 
@@ -115,8 +112,8 @@ fn main() -> anyhow::Result<()> {
     let small_schema = Schema::parse_str(raw_small_schema)?;
     let big_schema = Schema::parse_str(raw_big_schema)?;
 
-    println!("{:?}", small_schema);
-    println!("{:?}", big_schema);
+    println!("{small_schema:?}");
+    println!("{big_schema:?}");
 
     let mut small_record = Record::new(&small_schema).unwrap();
     small_record.put("field", "foo");
diff --git a/lang/rust/avro/examples/generate_interop_data.rs 
b/lang/rust/avro/examples/generate_interop_data.rs
index eb830e1e3..72b4d10b2 100644
--- a/lang/rust/avro/examples/generate_interop_data.rs
+++ b/lang/rust/avro/examples/generate_interop_data.rs
@@ -86,10 +86,10 @@ fn main() -> anyhow::Result<()> {
         let suffix = if codec_name == "null" {
             "".to_owned()
         } else {
-            format!("_{}", codec_name)
+            format!("_{codec_name}")
         };
 
-        let file_name = format!("{}/rust{}.avro", data_folder, suffix);
+        let file_name = format!("{data_folder}/rust{suffix}.avro");
         let output_file = std::fs::File::create(&file_name)?;
 
         let mut writer = Writer::with_codec(&schema, 
BufWriter::new(output_file), codec);
@@ -98,7 +98,7 @@ fn main() -> anyhow::Result<()> {
         let datum = create_datum(&schema);
         writer.append(datum)?;
         writer.flush()?;
-        println!("Wrote {}", file_name);
+        println!("Wrote {file_name}");
     }
 
     Ok(())
diff --git a/lang/rust/avro/examples/test_interop_single_object_encoding.rs 
b/lang/rust/avro/examples/test_interop_single_object_encoding.rs
index 06fb753ff..ef13465d7 100644
--- a/lang/rust/avro/examples/test_interop_single_object_encoding.rs
+++ b/lang/rust/avro/examples/test_interop_single_object_encoding.rs
@@ -23,7 +23,7 @@ struct InteropMessage;
 
 impl AvroSchema for InteropMessage {
     fn get_schema() -> apache_avro::Schema {
-        let schema = std::fs::read_to_string(format!("{}/test_schema.avsc", 
RESOURCES_FOLDER))
+        let schema = 
std::fs::read_to_string(format!("{RESOURCES_FOLDER}/test_schema.avsc"))
             .expect("File should exist with schema inside");
         apache_avro::Schema::parse_str(schema.as_str())
             .expect("File should exist with schema inside")
@@ -49,7 +49,7 @@ impl From<InteropMessage> for Value {
 }
 
 fn main() {
-    let single_object = std::fs::read(format!("{}/test_message.bin", 
RESOURCES_FOLDER))
+    let single_object = 
std::fs::read(format!("{RESOURCES_FOLDER}/test_message.bin"))
         .expect("File with single object not found or error occurred while 
reading it.");
     test_write(&single_object);
     test_read(single_object);
diff --git a/lang/rust/avro/examples/to_value.rs 
b/lang/rust/avro/examples/to_value.rs
index 69cbe38b6..4a78383e2 100644
--- a/lang/rust/avro/examples/to_value.rs
+++ b/lang/rust/avro/examples/to_value.rs
@@ -24,6 +24,6 @@ struct Test {
 fn main() -> anyhow::Result<()> {
     let test = Test { a: 27, b: "foo" };
     let value = apache_avro::to_value(test)?;
-    println!("{:?}", value);
+    println!("{value:?}");
     Ok(())
 }
diff --git a/lang/rust/avro/src/de.rs b/lang/rust/avro/src/de.rs
index 9204ed146..75ac229c8 100644
--- a/lang/rust/avro/src/de.rs
+++ b/lang/rust/avro/src/de.rs
@@ -167,8 +167,7 @@ impl<'de> de::EnumAccess<'de> for EnumDeserializer<'de> {
                     self,
                 )),
                 (field, Value::String(_)) => Err(de::Error::custom(format!(
-                    "Expected first field named 'type': got '{}' instead",
-                    field
+                    "Expected first field named 'type': got '{field}' instead"
                 ))),
                 (_, _) => Err(de::Error::custom(
                     "Expected first field of type String or Enum for the type 
name".to_string(),
diff --git a/lang/rust/avro/src/encode.rs b/lang/rust/avro/src/encode.rs
index 2ae48f91c..40f4ee0f7 100644
--- a/lang/rust/avro/src/encode.rs
+++ b/lang/rust/avro/src/encode.rs
@@ -202,7 +202,7 @@ pub(crate) fn encode_internal<S: Borrow<Schema>>(
             } = *schema
             {
                 let record_namespace = 
name.fully_qualified_name(enclosing_namespace).namespace;
-                for &(ref name, ref value) in fields.iter() {
+                for (name, value) in fields.iter() {
                     match lookup.get(name) {
                         Some(idx) => {
                             encode_internal(
@@ -216,7 +216,7 @@ pub(crate) fn encode_internal<S: Borrow<Schema>>(
                         None => {
                             return Err(Error::NoEntryInLookupTable(
                                 name.clone(),
-                                format!("{:?}", lookup),
+                                format!("{lookup:?}"),
                             ));
                         }
                     }
diff --git a/lang/rust/avro/src/reader.rs b/lang/rust/avro/src/reader.rs
index 3c8ea09b1..442f13075 100644
--- a/lang/rust/avro/src/reader.rs
+++ b/lang/rust/avro/src/reader.rs
@@ -582,10 +582,9 @@ mod tests {
         let avro_datum = from_avro_datum(&schema, &mut encoded, None).unwrap();
         let parsed_record: TestRecord3240 = match &avro_datum {
             Value::Record(_) => 
from_value::<TestRecord3240>(&avro_datum).unwrap(),
-            unexpected => panic!(
-                "could not map avro data to struct, found unexpected: {:?}",
-                unexpected
-            ),
+            unexpected => {
+                panic!("could not map avro data to struct, found unexpected: 
{unexpected:?}")
+            }
         };
 
         assert_eq!(parsed_record, expected_record);
@@ -747,7 +746,7 @@ mod tests {
                                 }
                             }
                         }
-                        (key, value) => panic!("Unexpected pair: {:?} -> 
{:?}", key, value),
+                        (key, value) => panic!("Unexpected pair: {key:?} -> 
{value:?}"),
                     }
                 }
                 TestSingleObjectReader {
@@ -756,7 +755,7 @@ mod tests {
                     c,
                 }
             } else {
-                panic!("Expected a Value::Record but was {:?}", obj)
+                panic!("Expected a Value::Record but was {obj:?}")
             }
         }
     }
diff --git a/lang/rust/avro/src/schema.rs b/lang/rust/avro/src/schema.rs
index 6aa1d7fe0..02e7c37be 100644
--- a/lang/rust/avro/src/schema.rs
+++ b/lang/rust/avro/src/schema.rs
@@ -57,7 +57,7 @@ impl fmt::Display for SchemaFingerprint {
             "{}",
             self.bytes
                 .iter()
-                .map(|byte| format!("{:02x}", byte))
+                .map(|byte| format!("{byte:02x}"))
                 .collect::<Vec<String>>()
                 .join("")
         )
@@ -348,10 +348,7 @@ impl<'de> Deserialize<'de> for Name {
             if let Value::Object(json) = value {
                 Name::parse(&json).map_err(Error::custom)
             } else {
-                Err(Error::custom(format!(
-                    "Expected a JSON object: {:?}",
-                    value
-                )))
+                Err(Error::custom(format!("Expected a JSON object: 
{value:?}")))
             }
         })
     }
@@ -752,7 +749,7 @@ impl Schema {
     /// 
https://avro.apache.org/docs/1.8.2/spec.html#Parsing+Canonical+Form+for+Schemas
     pub fn canonical_form(&self) -> String {
         let json = serde_json::to_value(self)
-            .unwrap_or_else(|e| panic!("Cannot parse Schema from JSON: {0}", 
e));
+            .unwrap_or_else(|e| panic!("Cannot parse Schema from JSON: {e}"));
         parsing_canonical_form(&json)
     }
 
@@ -965,7 +962,7 @@ impl Parser {
             key: &'static str,
         ) -> Result<DecimalMetadata, Error> {
             match complex.get(key) {
-                Some(&Value::Number(ref value)) => 
parse_json_integer_for_decimal(value),
+                Some(Value::Number(value)) => 
parse_json_integer_for_decimal(value),
                 None => {
                     if key == "scale" {
                         Ok(0)
@@ -1071,7 +1068,7 @@ impl Parser {
         }
 
         match complex.get("logicalType") {
-            Some(&Value::String(ref t)) => match t.as_str() {
+            Some(Value::String(t)) => match t.as_str() {
                 "decimal" => {
                     let inner = Box::new(logical_verify_type(
                         complex,
@@ -1157,7 +1154,7 @@ impl Parser {
             _ => {}
         }
         match complex.get("type") {
-            Some(&Value::String(ref t)) => match t.as_str() {
+            Some(Value::String(t)) => match t.as_str() {
                 "record" => self.parse_record(complex, enclosing_namespace),
                 "enum" => self.parse_enum(complex, enclosing_namespace),
                 "array" => self.parse_array(complex, enclosing_namespace),
@@ -1165,8 +1162,8 @@ impl Parser {
                 "fixed" => self.parse_fixed(complex, enclosing_namespace),
                 other => self.parse_known_schema(other, enclosing_namespace),
             },
-            Some(&Value::Object(ref data)) => self.parse_complex(data, 
enclosing_namespace),
-            Some(&Value::Array(ref variants)) => {
+            Some(Value::Object(data)) => self.parse_complex(data, 
enclosing_namespace),
+            Some(Value::Array(variants)) => {
                 let default = complex.get("default");
                 self.parse_union(variants, enclosing_namespace, default)
             }
@@ -1476,7 +1473,7 @@ fn fix_aliases_namespace(aliases: Option<Vec<String>>, 
namespace: &Namespace) ->
             .map(|alias| {
                 if alias.find('.').is_none() {
                     match namespace {
-                        Some(ref ns) => format!("{}.{}", ns, alias),
+                        Some(ref ns) => format!("{ns}.{alias}"),
                         None => alias.clone(),
                     }
                 } else {
@@ -1689,10 +1686,7 @@ fn parsing_canonical_form(schema: &Value) -> String {
         Value::Object(map) => pcf_map(map),
         Value::String(s) => pcf_string(s),
         Value::Array(v) => pcf_array(v),
-        json => panic!(
-            "got invalid JSON value for canonical form of schema: {0}",
-            json
-        ),
+        json => panic!("got invalid JSON value for canonical form of schema: 
{json}"),
     }
 }
 
@@ -1719,9 +1713,7 @@ fn pcf_map(schema: &Map<String, Value>) -> String {
             // Invariant: Only valid schemas. Must be a string.
             let name = v.as_str().unwrap();
             let n = match ns {
-                Some(namespace) if !name.contains('.') => {
-                    Cow::Owned(format!("{}.{}", namespace, name))
-                }
+                Some(namespace) if !name.contains('.') => 
Cow::Owned(format!("{namespace}.{name}")),
                 _ => Cow::Borrowed(name),
             };
 
@@ -1753,7 +1745,7 @@ fn pcf_map(schema: &Map<String, Value>) -> String {
         .map(|(_, v)| v)
         .collect::<Vec<_>>()
         .join(",");
-    format!("{{{}}}", inter)
+    format!("{{{inter}}}")
 }
 
 fn pcf_array(arr: &[Value]) -> String {
@@ -1762,11 +1754,11 @@ fn pcf_array(arr: &[Value]) -> String {
         .map(parsing_canonical_form)
         .collect::<Vec<String>>()
         .join(",");
-    format!("[{}]", inter)
+    format!("[{inter}]")
 }
 
 fn pcf_string(s: &str) -> String {
-    format!("\"{}\"", s)
+    format!("\"{s}\"")
 }
 
 const RESERVED_FIELDS: &[&str] = &[
@@ -3817,7 +3809,7 @@ mod tests {
         if let Schema::Record { ref aliases, .. } = schema {
             assert_avro_3512_aliases(aliases);
         } else {
-            panic!("The Schema should be a record: {:?}", schema);
+            panic!("The Schema should be a record: {schema:?}");
         }
     }
 
@@ -3841,7 +3833,7 @@ mod tests {
         if let Schema::Enum { ref aliases, .. } = schema {
             assert_avro_3512_aliases(aliases);
         } else {
-            panic!("The Schema should be an enum: {:?}", schema);
+            panic!("The Schema should be an enum: {schema:?}");
         }
     }
 
@@ -3863,7 +3855,7 @@ mod tests {
         if let Schema::Fixed { ref aliases, .. } = schema {
             assert_avro_3512_aliases(aliases);
         } else {
-            panic!("The Schema should be a fixed: {:?}", schema);
+            panic!("The Schema should be a fixed: {schema:?}");
         }
     }
 
diff --git a/lang/rust/avro/src/schema_compatibility.rs 
b/lang/rust/avro/src/schema_compatibility.rs
index 843a139df..b691041e5 100644
--- a/lang/rust/avro/src/schema_compatibility.rs
+++ b/lang/rust/avro/src/schema_compatibility.rs
@@ -437,7 +437,7 @@ mod tests {
             .map(|s| s.canonical_form())
             .collect::<Vec<String>>()
             .join(",");
-        Schema::parse_str(&format!("[{}]", schema_string)).unwrap()
+        Schema::parse_str(&format!("[{schema_string}]")).unwrap()
     }
 
     fn empty_union_schema() -> Schema {
diff --git a/lang/rust/avro/src/types.rs b/lang/rust/avro/src/types.rs
index 940ca17aa..9f3f3d253 100644
--- a/lang/rust/avro/src/types.rs
+++ b/lang/rust/avro/src/types.rs
@@ -359,7 +359,7 @@ impl Value {
             (None, None) => None,
             (None, s @ Some(_)) => s,
             (s @ Some(_), None) => s,
-            (Some(reason1), Some(reason2)) => Some(format!("{}\n{}", reason1, 
reason2)),
+            (Some(reason1), Some(reason2)) => 
Some(format!("{reason1}\n{reason2}")),
         }
     }
 
@@ -370,7 +370,7 @@ impl Value {
         enclosing_namespace: &Namespace,
     ) -> Option<String> {
         match (self, schema) {
-            (_, &Schema::Ref { ref name }) => {
+            (_, Schema::Ref { name }) => {
                 let name = name.fully_qualified_name(enclosing_namespace);
                 names.get(&name).map_or_else(
                     || {
@@ -411,14 +411,13 @@ impl Value {
             (&Value::Fixed(n, _), &Schema::Fixed { size, .. }) => {
                 if n != size {
                     Some(format!(
-                        "The value's size ({}) is different than the schema's 
size ({})",
-                        n, size
+                        "The value's size ({n}) is different than the schema's 
size ({size})"
                     ))
                 } else {
                     None
                 }
             }
-            (&Value::Bytes(ref b), &Schema::Fixed { size, .. }) => {
+            (Value::Bytes(b), &Schema::Fixed { size, .. }) => {
                 if b.len() != size {
                     Some(format!(
                         "The bytes' length ({}) is different than the schema's 
size ({})",
@@ -432,8 +431,7 @@ impl Value {
             (&Value::Fixed(n, _), &Schema::Duration) => {
                 if n != 12 {
                     Some(format!(
-                        "The value's size ('{}') must be exactly 12 to be a 
Duration",
-                        n
+                        "The value's size ('{n}') must be exactly 12 to be a 
Duration"
                     ))
                 } else {
                     None
@@ -441,42 +439,40 @@ impl Value {
             }
             // TODO: check precision against n
             (&Value::Fixed(_n, _), &Schema::Decimal { .. }) => None,
-            (&Value::String(ref s), &Schema::Enum { ref symbols, .. }) => {
+            (Value::String(s), Schema::Enum { symbols, .. }) => {
                 if !symbols.contains(s) {
-                    Some(format!("'{}' is not a member of the possible 
symbols", s))
+                    Some(format!("'{s}' is not a member of the possible 
symbols"))
                 } else {
                     None
                 }
             }
-            (&Value::Enum(i, ref s), &Schema::Enum { ref symbols, .. }) => 
symbols
+            (&Value::Enum(i, ref s), Schema::Enum { symbols, .. }) => symbols
                 .get(i as usize)
                 .map(|ref symbol| {
                     if symbol != &s {
-                        Some(format!("Symbol '{}' is not at position '{}'", s, 
i))
+                        Some(format!("Symbol '{s}' is not at position '{i}'"))
                     } else {
                         None
                     }
                 })
-                .unwrap_or_else(|| Some(format!("No symbol at position '{}'", 
i))),
+                .unwrap_or_else(|| Some(format!("No symbol at position 
'{i}'"))),
             // (&Value::Union(None), &Schema::Union(_)) => None,
-            (&Value::Union(i, ref value), &Schema::Union(ref inner)) => inner
+            (&Value::Union(i, ref value), Schema::Union(inner)) => inner
                 .variants()
                 .get(i as usize)
                 .map(|schema| value.validate_internal(schema, names, 
enclosing_namespace))
-                .unwrap_or_else(|| Some(format!("No schema in the union at 
position '{}'", i))),
-            (v, &Schema::Union(ref inner)) => match inner.find_schema(v) {
+                .unwrap_or_else(|| Some(format!("No schema in the union at 
position '{i}'"))),
+            (v, Schema::Union(inner)) => match inner.find_schema(v) {
                 Some(_) => None,
                 None => Some("Could not find matching type in 
union".to_string()),
             },
-            (&Value::Array(ref items), &Schema::Array(ref inner)) => {
-                items.iter().fold(None, |acc, item| {
-                    Value::accumulate(
-                        acc,
-                        item.validate_internal(inner, names, 
enclosing_namespace),
-                    )
-                })
-            }
-            (&Value::Map(ref items), &Schema::Map(ref inner)) => {
+            (Value::Array(items), Schema::Array(inner)) => 
items.iter().fold(None, |acc, item| {
+                Value::accumulate(
+                    acc,
+                    item.validate_internal(inner, names, enclosing_namespace),
+                )
+            }),
+            (Value::Map(items), Schema::Map(inner)) => {
                 items.iter().fold(None, |acc, (_, value)| {
                     Value::accumulate(
                         acc,
@@ -484,14 +480,7 @@ impl Value {
                     )
                 })
             }
-            (
-                &Value::Record(ref record_fields),
-                &Schema::Record {
-                    ref fields,
-                    ref lookup,
-                    ..
-                },
-            ) => {
+            (Value::Record(record_fields), Schema::Record { fields, lookup, .. 
}) => {
                 let non_nullable_fields_count =
                     fields.iter().filter(|&rf| !rf.is_nullable()).count();
 
@@ -526,15 +515,12 @@ impl Value {
                             }
                             None => Value::accumulate(
                                 acc,
-                                Some(format!(
-                                    "There is no schema field for field '{}'",
-                                    field_name
-                                )),
+                                Some(format!("There is no schema field for 
field '{field_name}'")),
                             ),
                         }
                     })
             }
-            (&Value::Map(ref items), &Schema::Record { ref fields, .. }) => {
+            (Value::Map(items), Schema::Record { fields, .. }) => {
                 fields.iter().fold(None, |acc, field| {
                     if let Some(item) = items.get(&field.name) {
                         let res = item.validate_internal(&field.schema, names, 
enclosing_namespace);
diff --git a/lang/rust/avro/src/writer.rs b/lang/rust/avro/src/writer.rs
index 82a5b1387..0c8e4661f 100644
--- a/lang/rust/avro/src/writer.rs
+++ b/lang/rust/avro/src/writer.rs
@@ -1077,10 +1077,7 @@ mod tests {
             Err(e @ Error::FileHeaderAlreadyWritten) => {
                 assert_eq!(e.to_string(), "The file metadata is already 
flushed.")
             }
-            Err(e) => panic!(
-                "Unexpected error occurred while writing user metadata: {:?}",
-                e
-            ),
+            Err(e) => panic!("Unexpected error occurred while writing user 
metadata: {e:?}"),
             Ok(_) => panic!("Expected an error that metadata cannot be added 
after adding data"),
         }
     }
@@ -1093,11 +1090,10 @@ mod tests {
         let key = "avro.stringKey".to_string();
         match writer.add_user_metadata(key.clone(), "value") {
             Err(ref e @ Error::InvalidMetadataKey(_)) => {
-                assert_eq!(e.to_string(), format!("Metadata keys starting with 
'avro.' are reserved for internal usage: {}.", key))
+                assert_eq!(e.to_string(), format!("Metadata keys starting with 
'avro.' are reserved for internal usage: {key}."))
             }
             Err(e) => panic!(
-                "Unexpected error occurred while writing user metadata with 
reserved prefix ('avro.'): {:?}",
-                e
+                "Unexpected error occurred while writing user metadata with 
reserved prefix ('avro.'): {e:?}"
             ),
             Ok(_) => panic!("Expected an error that the metadata key cannot be 
prefixed with 'avro.'"),
         }
diff --git a/lang/rust/avro/tests/append_to_existing.rs 
b/lang/rust/avro/tests/append_to_existing.rs
index 4f92f45e9..7b3874746 100644
--- a/lang/rust/avro/tests/append_to_existing.rs
+++ b/lang/rust/avro/tests/append_to_existing.rs
@@ -79,8 +79,8 @@ fn check(value: AvroResult<Value>, expected: i32) {
                 (_, Value::Int(actual)) => assert_eq!(&expected, actual),
                 _ => panic!("The field value type must be an Int: {:?}!", 
&fields[0]),
             },
-            _ => panic!("The value type must be a Record: {:?}!", value),
+            _ => panic!("The value type must be a Record: {value:?}!"),
         },
-        Err(e) => panic!("Error while reading the data: {:?}", e),
+        Err(e) => panic!("Error while reading the data: {e:?}"),
     }
 }
diff --git a/lang/rust/avro/tests/io.rs b/lang/rust/avro/tests/io.rs
index fc316b060..9d3dc7b79 100644
--- a/lang/rust/avro/tests/io.rs
+++ b/lang/rust/avro/tests/io.rs
@@ -104,9 +104,7 @@ fn test_validate() {
         let schema = Schema::parse_str(raw_schema).unwrap();
         assert!(
             value.validate(&schema),
-            "value {:?} does not validate schema: {}",
-            value,
-            raw_schema
+            "value {value:?} does not validate schema: {raw_schema}"
         );
     }
 }
@@ -160,10 +158,7 @@ fn test_schema_promotion() {
                 Some(&reader_schema),
             )
             .unwrap_or_else(|_| {
-                panic!(
-                    "failed to decode {:?} with schema: {:?}",
-                    original_value, reader_raw_schema,
-                )
+                panic!("failed to decode {original_value:?} with schema: 
{reader_raw_schema:?}",)
             });
             assert_eq!(decoded, promotable_values[j]);
         }
@@ -196,10 +191,9 @@ fn test_default_value() {
                 "type": "record",
                 "name": "Test",
                 "fields": [
-                    {{"name": "H", "type": {}, "default": {}}}
+                    {{"name": "H", "type": {field_type}, "default": 
{default_json}}}
                 ]
-            }}"#,
-            field_type, default_json
+            }}"#
         ))
         .unwrap();
         let datum_to_read = Value::Record(vec![("H".to_string(), 
default_datum.clone())]);
@@ -320,6 +314,6 @@ fn test_type_exception() -> Result<(), String> {
     match encoded {
         Ok(_) => Err(String::from("Expected ValidationError, got Ok")),
         Err(Error::Validation) => Ok(()),
-        Err(ref e) => Err(format!("Expected ValidationError, got {:?}", e)),
+        Err(ref e) => Err(format!("Expected ValidationError, got {e:?}")),
     }
 }
diff --git a/lang/rust/avro/tests/schema.rs b/lang/rust/avro/tests/schema.rs
index 0fc18921f..4f7270d82 100644
--- a/lang/rust/avro/tests/schema.rs
+++ b/lang/rust/avro/tests/schema.rs
@@ -653,10 +653,10 @@ fn test_correct_recursive_extraction() {
                 assert_eq!("X", recursive_type.name.as_str());
             }
         } else {
-            panic!("inner schema {:?} should have been a record", inner_schema)
+            panic!("inner schema {inner_schema:?} should have been a record")
         }
     } else {
-        panic!("outer schema {:?} should have been a record", outer_schema)
+        panic!("outer schema {outer_schema:?} should have been a record")
     }
 }
 
@@ -668,15 +668,12 @@ fn test_parse() {
         if *valid {
             assert!(
                 schema.is_ok(),
-                "schema {} was supposed to be valid; error: {:?}",
-                raw_schema,
-                schema,
+                "schema {raw_schema} was supposed to be valid; error: 
{schema:?}",
             )
         } else {
             assert!(
                 schema.is_err(),
-                "schema {} was supposed to be invalid",
-                raw_schema
+                "schema {raw_schema} was supposed to be invalid"
             )
         }
     }
@@ -1268,10 +1265,7 @@ fn test_root_error_is_not_swallowed_on_parse_error() -> 
Result<(), String> {
         );
         Ok(())
     } else {
-        Err(format!(
-            "Expected serde_json::error::Error, got {:?}",
-            error
-        ))
+        Err(format!("Expected serde_json::error::Error, got {error:?}"))
     }
 }
 
@@ -1329,7 +1323,7 @@ fn test_record_schema_with_cyclic_references() {
 
     let mut writer = Writer::with_codec(&schema, Vec::new(), Codec::Null);
     if let Err(err) = writer.append(datum) {
-        panic!("An error occurred while writing datum: {:?}", err)
+        panic!("An error occurred while writing datum: {err:?}")
     }
     let bytes = writer.into_inner().unwrap();
     assert_eq!(316, bytes.len());
@@ -1339,7 +1333,7 @@ fn test_record_schema_with_cyclic_references() {
             Some(value) => log::debug!("{:?}", value.unwrap()),
             None => panic!("No value was read!"),
         },
-        Err(err) => panic!("An error occurred while reading datum: {:?}", err),
+        Err(err) => panic!("An error occurred while reading datum: {err:?}"),
     }
 }
 
diff --git a/lang/rust/avro_derive/Cargo.toml b/lang/rust/avro_derive/Cargo.toml
index 36b995560..d0bb0e501 100644
--- a/lang/rust/avro_derive/Cargo.toml
+++ b/lang/rust/avro_derive/Cargo.toml
@@ -23,7 +23,8 @@ description = "A library for deriving Avro schemata from Rust 
structs and enums"
 license = "Apache-2.0"
 readme = "README.md"
 repository = "https://github.com/apache/avro";
-edition = "2018"
+edition = "2021"
+rust-version = "1.60.0"
 keywords = ["avro", "data", "serialization", "derive"]
 categories = ["encoding"]
 documentation = "https://docs.rs/apache-avro-derive";
diff --git a/lang/rust/avro_derive/src/lib.rs b/lang/rust/avro_derive/src/lib.rs
index 8f6a9b70a..77b0c6a24 100644
--- a/lang/rust/avro_derive/src/lib.rs
+++ b/lang/rust/avro_derive/src/lib.rs
@@ -139,7 +139,7 @@ fn get_data_struct_schema_def(
                             .map_err(|e| {
                                 vec![syn::Error::new(
                                     field.ident.span(),
-                                    format!("Invalid avro default json: \n{}", 
e),
+                                    format!("Invalid avro default json: 
\n{e}"),
                                 )]
                             })?;
                         quote! {
@@ -268,7 +268,7 @@ fn type_to_schema_expr(ty: &Type) -> Result<TokenStream, 
Vec<syn::Error>> {
     } else {
         Err(vec![syn::Error::new_spanned(
             ty,
-            format!("Unable to generate schema for type: {:?}", ty),
+            format!("Unable to generate schema for type: {ty:?}"),
         )])
     }
 }
@@ -327,7 +327,7 @@ fn preserve_vec(op: Vec<impl quote::ToTokens>) -> 
TokenStream {
 }
 
 fn darling_to_syn(e: darling::Error) -> Vec<syn::Error> {
-    let msg = format!("{}", e);
+    let msg = format!("{e}");
     let token_errors = e.write_errors();
     vec![syn::Error::new(token_errors.span(), msg)]
 }
@@ -349,8 +349,7 @@ mod tests {
                 assert!(derive_avro_schema(&mut input).is_ok())
             }
             Err(error) => panic!(
-                "Failed to parse as derive input when it should be able to. 
Error: {:?}",
-                error
+                "Failed to parse as derive input when it should be able to. 
Error: {error:?}"
             ),
         };
     }
@@ -366,8 +365,7 @@ mod tests {
                 assert!(derive_avro_schema(&mut input).is_err())
             }
             Err(error) => panic!(
-                "Failed to parse as derive input when it should be able to. 
Error: {:?}",
-                error
+                "Failed to parse as derive input when it should be able to. 
Error: {error:?}"
             ),
         };
     }
@@ -383,8 +381,7 @@ mod tests {
                 assert!(derive_avro_schema(&mut input).is_err())
             }
             Err(error) => panic!(
-                "Failed to parse as derive input when it should be able to. 
Error: {:?}",
-                error
+                "Failed to parse as derive input when it should be able to. 
Error: {error:?}"
             ),
         };
     }
@@ -401,8 +398,7 @@ mod tests {
                 assert!(derive_avro_schema(&mut input).is_ok())
             }
             Err(error) => panic!(
-                "Failed to parse as derive input when it should be able to. 
Error: {:?}",
-                error
+                "Failed to parse as derive input when it should be able to. 
Error: {error:?}"
             ),
         };
     }
@@ -422,8 +418,7 @@ mod tests {
                 assert!(derive_avro_schema(&mut input).is_ok())
             }
             Err(error) => panic!(
-                "Failed to parse as derive input when it should be able to. 
Error: {:?}",
-                error
+                "Failed to parse as derive input when it should be able to. 
Error: {error:?}"
             ),
         };
     }
@@ -443,8 +438,7 @@ mod tests {
                 assert!(derive_avro_schema(&mut input).is_err())
             }
             Err(error) => panic!(
-                "Failed to parse as derive input when it should be able to. 
Error: {:?}",
-                error
+                "Failed to parse as derive input when it should be able to. 
Error: {error:?}"
             ),
         };
     }
@@ -468,8 +462,7 @@ mod tests {
                     .contains("namespace.testing"))
             }
             Err(error) => panic!(
-                "Failed to parse as derive input when it should be able to. 
Error: {:?}",
-                error
+                "Failed to parse as derive input when it should be able to. 
Error: {error:?}"
             ),
         };
     }
@@ -488,8 +481,7 @@ mod tests {
                 assert!(derive_avro_schema(&mut input).is_ok())
             }
             Err(error) => panic!(
-                "Failed to parse as derive input when it should be able to. 
Error: {:?}",
-                error
+                "Failed to parse as derive input when it should be able to. 
Error: {error:?}"
             ),
         };
     }
diff --git a/lang/rust/avro_derive/tests/derive.rs 
b/lang/rust/avro_derive/tests/derive.rs
index a2ac0b6bf..a22c6525f 100644
--- a/lang/rust/avro_derive/tests/derive.rs
+++ b/lang/rust/avro_derive/tests/derive.rs
@@ -60,7 +60,7 @@ mod test_derive {
         let schema = T::get_schema();
         let mut writer = Writer::new(&schema, Vec::new());
         if let Err(e) = writer.append_ser(obj) {
-            panic!("{:?}", e);
+            panic!("{e:?}");
         }
         writer.into_inner().unwrap()
     }
@@ -77,7 +77,7 @@ mod test_derive {
                 Ok(value) => {
                     return from_value::<T>(&value).unwrap();
                 }
-                Err(e) => panic!("{:?}", e),
+                Err(e) => panic!("{e:?}"),
             }
         }
         unreachable!()
@@ -1466,8 +1466,7 @@ mod test_derive {
             }
         } else {
             panic!(
-                "TestBasicStructWithSkipAttribute schema must be a record 
schema: {:?}",
-                derived_schema
+                "TestBasicStructWithSkipAttribute schema must be a record 
schema: {derived_schema:?}"
             )
         }
         assert_eq!(schema, derived_schema);
@@ -1533,8 +1532,7 @@ mod test_derive {
             }
         } else {
             panic!(
-                "TestBasicStructWithRenameAttribute schema must be a record 
schema: {:?}",
-                derived_schema
+                "TestBasicStructWithRenameAttribute schema must be a record 
schema: {derived_schema:?}"
             )
         }
         assert_eq!(schema, derived_schema);
@@ -1558,7 +1556,7 @@ mod test_derive {
             let field = fields.get(0).expect("TestRawIdent must contain a 
field");
             assert_eq!(field.name, "type");
         } else {
-            panic!("Unexpected schema type for {:?}", derived_schema)
+            panic!("Unexpected schema type for {derived_schema:?}")
         }
     }
 }
diff --git a/lang/rust/avro_test_helper/Cargo.toml 
b/lang/rust/avro_test_helper/Cargo.toml
index 1589db16a..fb2399921 100644
--- a/lang/rust/avro_test_helper/Cargo.toml
+++ b/lang/rust/avro_test_helper/Cargo.toml
@@ -18,7 +18,8 @@
 [package]
 name = "apache-avro-test-helper"
 version = "0.15.0"
-edition = "2018"
+edition = "2021"
+rust-version = "1.60.0"
 description = "Apache Avro tests helper."
 authors = ["Apache Avro team <[email protected]>"]
 license = "Apache-2.0"
diff --git a/lang/rust/avro_test_helper/src/logger.rs 
b/lang/rust/avro_test_helper/src/logger.rs
index 87e7d7148..09fc1bede 100644
--- a/lang/rust/avro_test_helper/src/logger.rs
+++ b/lang/rust/avro_test_helper/src/logger.rs
@@ -57,10 +57,9 @@ pub fn clear_log_messages() {
 
 pub fn assert_not_logged(unexpected_message: &str) {
     match LOG_MESSAGES.borrow().last() {
-        Some(last_log) if last_log == unexpected_message => panic!(
-            "The following log message should not have been logged: '{}'",
-            unexpected_message
-        ),
+        Some(last_log) if last_log == unexpected_message => {
+            panic!("The following log message should not have been logged: 
'{unexpected_message}'")
+        }
         _ => (),
     }
 }
@@ -74,7 +73,7 @@ pub(crate) fn install() {
     log::set_logger(&*TEST_LOGGER)
         .map(|_| log::set_max_level(LevelFilter::Trace))
         .map_err(|err| {
-            eprintln!("Failed to set the custom logger: {:?}", err);
+            eprintln!("Failed to set the custom logger: {err:?}");
         })
         .unwrap();
 }
diff --git a/lang/rust/fuzz/Cargo.toml b/lang/rust/fuzz/Cargo.toml
index b2e38b482..c811e481d 100644
--- a/lang/rust/fuzz/Cargo.toml
+++ b/lang/rust/fuzz/Cargo.toml
@@ -19,7 +19,8 @@
 name = "apache-avro-fuzz"
 version = "0.0.0"
 publish = false
-edition = "2018"
+edition = "2021"
+rust-version = "1.60.0"
 
 [package.metadata]
 cargo-fuzz = true
diff --git a/lang/rust/wasm-demo/Cargo.toml b/lang/rust/wasm-demo/Cargo.toml
index c2dda12b0..cfc665570 100644
--- a/lang/rust/wasm-demo/Cargo.toml
+++ b/lang/rust/wasm-demo/Cargo.toml
@@ -23,7 +23,8 @@ description = "A demo project for testing apache_avro in 
WebAssembly"
 license = "Apache-2.0"
 readme = "README.md"
 repository = "https://github.com/apache/avro";
-edition = "2018"
+edition = "2021"
+rust-version = "1.60.0"
 keywords = ["avro", "data", "serialization", "wasm", "web assembly"]
 categories = ["encoding"]
 documentation = "https://docs.rs/apache-avro";


Reply via email to