From e7e7b26768b78c1c70dcb251cac7e6af69aa1df8 Mon Sep 17 00:00:00 2001 From: Matthijs Brobbel Date: Mon, 30 Jun 2025 14:17:45 +0200 Subject: [PATCH 1/2] chore: fix clippy 1.88 warnings --- py/build.rs | 6 +++--- rs/src/export/html/mod.rs | 8 ++++---- rs/src/output/diagnostic.rs | 17 +++++------------ rs/src/output/extension/simple/type_class.rs | 4 ++-- rs/src/output/path.rs | 2 +- rs/src/output/primitive_data.rs | 2 +- rs/src/output/type_system/data/class.rs | 6 +++--- rs/src/output/type_system/data/type.rs | 2 +- rs/src/output/type_system/meta/pattern.rs | 6 +++--- rs/src/parse/expressions/references/scalar.rs | 2 +- rs/src/parse/relations/join.rs | 18 +++++++----------- rs/src/util/string.rs | 8 ++++---- tests/src/find_protoc.rs | 2 +- 13 files changed, 36 insertions(+), 47 deletions(-) diff --git a/py/build.rs b/py/build.rs index 2a2522f7..ac3fb32d 100644 --- a/py/build.rs +++ b/py/build.rs @@ -83,7 +83,7 @@ fn main() { { // Use vendored protobuf compiler if requested. protoc_path = protobuf_src::protoc(); - println!("cargo:warning=Using vendored protoc: {:?}", protoc_path); + println!("cargo:warning=Using vendored protoc: {protoc_path:?}"); } #[cfg(not(feature = "protoc"))] { @@ -106,7 +106,7 @@ fn main() { if !output.status.success() { eprintln!("cmd: {:?}", cmd.get_program()); for arg in cmd.get_args() { - eprintln!("arg: {:?}", arg); + eprintln!("arg: {arg:?}"); } panic!("{:?}", output); } @@ -156,7 +156,7 @@ fn main() { } else { line }; - writeln!(output, "{}", line).unwrap(); + writeln!(output, "{line}").unwrap(); } } diff --git a/rs/src/export/html/mod.rs b/rs/src/export/html/mod.rs index 8763ec75..5a73361a 100644 --- a/rs/src/export/html/mod.rs +++ b/rs/src/export/html/mod.rs @@ -224,7 +224,7 @@ fn format_span(class: &'static str, text: S) -> String { /// Creates a span with the given class name. fn format_span_html(class: &'static str, html: S) -> String { - format!("{}", html) + format!("{html}") } /// Formats a diagnostic message box. path should be the node that the @@ -242,7 +242,7 @@ fn format_diagnostic( if with_path { diag.to_string() } else { - format!("{:#}", diag) + format!("{diag:#}") }, ); let cause = if &diag.path == path { @@ -452,7 +452,7 @@ fn format_data_type(prefix: &str, data_type: &data::Type) -> Vec { let mut html = vec![]; if data_type.parameters().is_empty() { - html.push(format_data_type_card(&format!("{prefix}: {:#}", data_type))); + html.push(format_data_type_card(&format!("{prefix}: {data_type:#}"))); } else { html.push("
\n".to_string()); html.push(format!("{prefix}: {}", html_escape(data_type.to_string()))); @@ -624,7 +624,7 @@ pub fn export( // Generate and write header. let font_awesome_b64 = general_purpose::STANDARD.encode(FONT_AWESOME); - write!(out, "{HEADER1}{}{HEADER2}", font_awesome_b64)?; + write!(out, "{HEADER1}{font_awesome_b64}{HEADER2}")?; // Emit metadata. writeln!(out, "
")?; diff --git a/rs/src/output/diagnostic.rs b/rs/src/output/diagnostic.rs index 1cf54255..19b86037 100644 --- a/rs/src/output/diagnostic.rs +++ b/rs/src/output/diagnostic.rs @@ -378,7 +378,7 @@ impl Classification { /// Returns the name of the classiciation. pub fn name(&self) -> String { - format!("{:?}", self) + format!("{self:?}") } /// Returns the group code for this classification. @@ -388,8 +388,7 @@ impl Classification { /// Returns the group variant for this classification. pub fn group(&self) -> Classification { - Self::from_group(self.group_code()) - .unwrap_or_else(|| panic!("missing group for {:?}", self)) + Self::from_group(self.group_code()).unwrap_or_else(|| panic!("missing group for {self:?}")) } /// Returns the code for this classification within its group. @@ -402,10 +401,7 @@ impl Classification { self.get_str("Description") .or_else(|| self.get_str("HiddenDescription")) .unwrap_or_else(|| { - panic!( - "missing Description or HiddenDescription property for {:?}", - self - ) + panic!("missing Description or HiddenDescription property for {self:?}") }) } @@ -644,15 +640,12 @@ mod tests { if group != Classification::Unclassified { assert!( class.name().starts_with(&group.name()), - "incorrect group prefix for {:?}, should start with {:?}", - class, - group + "incorrect group prefix for {class:?}, should start with {group:?}" ); } assert!( descriptions.insert(class.description().to_string()), - "duplicate description for {:?}", - class + "duplicate description for {class:?}" ); } } diff --git a/rs/src/output/extension/simple/type_class.rs b/rs/src/output/extension/simple/type_class.rs index 0765f725..c0d13c51 100644 --- a/rs/src/output/extension/simple/type_class.rs +++ b/rs/src/output/extension/simple/type_class.rs @@ -142,7 +142,7 @@ impl ParameterInfo for Definition { if self.parameters_variadic && index + 1 >= self.parameter_slots.len() { if let Some(slot) = self.parameter_slots.last() { return Some(if slot.name.is_empty() { - format!("{}", index) + format!("{index}") } else { format!("{}.{}", slot.name, index + 1 - self.parameter_slots.len()) }); @@ -150,7 +150,7 @@ impl ParameterInfo for Definition { } self.parameter_slots.get(index).map(|slot| { if slot.name.is_empty() { - format!("{}", index) + format!("{index}") } else { slot.name.clone() } diff --git a/rs/src/output/path.rs b/rs/src/output/path.rs index 0c4f7a63..63babffb 100644 --- a/rs/src/output/path.rs +++ b/rs/src/output/path.rs @@ -58,7 +58,7 @@ impl PathElement { /// Same as to_string(), but doesn't include the dot prefix for the /// variants that would normally have one. pub fn to_string_without_dot(&self) -> String { - format!("{:#}", self) + format!("{self:#}") } } diff --git a/rs/src/output/primitive_data.rs b/rs/src/output/primitive_data.rs index ea72e917..f9b3ad9d 100644 --- a/rs/src/output/primitive_data.rs +++ b/rs/src/output/primitive_data.rs @@ -42,7 +42,7 @@ fn hexdump(f: &mut std::fmt::Formatter<'_>, x: &[u8]) -> std::fmt::Result { if i > 0 { write!(f, " ")?; } - write!(f, "{:02X}", b)?; + write!(f, "{b:02X}")?; } Ok(()) } diff --git a/rs/src/output/type_system/data/class.rs b/rs/src/output/type_system/data/class.rs index cdd75237..776395e0 100644 --- a/rs/src/output/type_system/data/class.rs +++ b/rs/src/output/type_system/data/class.rs @@ -26,7 +26,7 @@ pub trait ParameterInfo { /// if the name is not known. fn parameter_name_or_index(&self, index: usize) -> String { self.parameter_name(index) - .unwrap_or_else(|| format!("{}", index)) + .unwrap_or_else(|| format!("{index}")) } /// Whether this type supports parameters. This is used to determine @@ -338,8 +338,8 @@ impl ParameterInfo for Compound { (Compound::FixedBinary, 0) => Some(String::from("length")), (Compound::Decimal, 0) => Some(String::from("precision")), (Compound::Decimal, 1) => Some(String::from("scale")), - (Compound::Struct, i) => Some(format!("{}", i)), - (Compound::NamedStruct, i) => Some(format!("{}", i)), + (Compound::Struct, i) => Some(format!("{i}")), + (Compound::NamedStruct, i) => Some(format!("{i}")), (Compound::List, 0) => Some(String::from("element")), (Compound::Map, 0) => Some(String::from("key")), (Compound::Map, 1) => Some(String::from("value")), diff --git a/rs/src/output/type_system/data/type.rs b/rs/src/output/type_system/data/type.rs index 56525287..0299edd1 100644 --- a/rs/src/output/type_system/data/type.rs +++ b/rs/src/output/type_system/data/type.rs @@ -46,7 +46,7 @@ impl Describe for Definition { if let data::Variation::UserDefined(variation) = &self.variation { write!(&mut name, "[{variation}]")?; } - write!(f, "{}", name)?; + write!(f, "{name}")?; let (_, limit) = limit.split(name.len()); if self.class.has_parameters() { write!(f, "<")?; diff --git a/rs/src/output/type_system/meta/pattern.rs b/rs/src/output/type_system/meta/pattern.rs index 77c95634..0afdc527 100644 --- a/rs/src/output/type_system/meta/pattern.rs +++ b/rs/src/output/type_system/meta/pattern.rs @@ -397,7 +397,7 @@ impl Pattern for Value { /// `MIRROR` nullability behavior. /// /// Syntax: a `?` followed by any identifier. -/// +/// /// ## Consistent bindings with nullability suffix /// /// (inconsistent = false, nullability = Some(pattern)) @@ -630,7 +630,7 @@ impl Describe for DataType { ) -> std::fmt::Result { let mut non_recursive = String::new(); if let Some(class) = &self.class { - write!(&mut non_recursive, "{}", class)?; + write!(&mut non_recursive, "{class}")?; } else { write!(&mut non_recursive, "typename")?; } @@ -641,7 +641,7 @@ impl Describe for DataType { x => write!(&mut non_recursive, "?{x}")?, } write!(&mut non_recursive, "{}", self.variation)?; - write!(f, "{}", non_recursive)?; + write!(f, "{non_recursive}")?; if let Some(parameters) = &self.parameters { write!(f, "<")?; util::string::describe_sequence(f, parameters, limit, 20, |f, param, _, limit| { diff --git a/rs/src/parse/expressions/references/scalar.rs b/rs/src/parse/expressions/references/scalar.rs index e40e41d1..e5abd0d2 100644 --- a/rs/src/parse/expressions/references/scalar.rs +++ b/rs/src/parse/expressions/references/scalar.rs @@ -170,7 +170,7 @@ fn parse_map_key( ); // Create description. - let description = format!(".[{}]", key); + let description = format!(".[{key}]"); // Determine result data type. let data_type = root.unwrap_map().unwrap_or_default(); diff --git a/rs/src/parse/relations/join.rs b/rs/src/parse/relations/join.rs index de5b3bcb..8da76e25 100644 --- a/rs/src/parse/relations/join.rs +++ b/rs/src/parse/relations/join.rs @@ -139,35 +139,31 @@ pub fn parse_join_rel(x: &substrait::JoinRel, y: &mut context::Context) -> diagn JoinType::Inner => format!( "Returns rows combining the row from the left and right \ input for each pair where the join expression yields true, \ - discarding rows where the join expression yields {}.", - nullable + discarding rows where the join expression yields {nullable}." ), JoinType::Outer => format!( "Returns rows combining the row from the left and right \ input for each pair where the join expression yields true, \ - discarding rows where the join expression yields {}. \ + discarding rows where the join expression yields {nullable}. \ If the join expression never yields true for any left or \ right row, this returns a row anyway, with the fields \ - corresponding to the other input set to null.", - nullable + corresponding to the other input set to null." ), JoinType::Left => format!( "Returns rows combining the row from the left and right \ input for each pair where the join expression yields true, \ - discarding rows where the join expression yields {}. \ + discarding rows where the join expression yields {nullable}. \ If the join expression never yields true for a row from the \ left, this returns a row anyway, with the fields corresponding \ - to the right input set to null.", - nullable + to the right input set to null." ), JoinType::Right => format!( "Returns rows combining the row from the left and right \ input for each pair where the join expression yields true, \ - discarding rows where the join expression yields {}. \ + discarding rows where the join expression yields {nullable}. \ If the join expression never yields true for a row from the \ right, this returns a row anyway, with the fields corresponding \ - to the left input set to null.", - nullable + to the left input set to null." ), JoinType::LeftSemi => "Filters rows from the left input, propagating a row only if \ the join expression yields true for that row combined with \ diff --git a/rs/src/util/string.rs b/rs/src/util/string.rs index 471c4c2c..e2f0fece 100644 --- a/rs/src/util/string.rs +++ b/rs/src/util/string.rs @@ -299,7 +299,7 @@ fn write_truncated_str( if quote { write!(f, "{}", as_quoted_string(&left_part))?; } else { - write!(f, "{}", left_part)?; + write!(f, "{left_part}")?; } } if let Some(n_right) = n_right { @@ -309,7 +309,7 @@ fn write_truncated_str( if quote { write!(f, "{}", as_quoted_string(&right_part))?; } else { - write!(f, "{}", right_part)?; + write!(f, "{right_part}")?; } } } @@ -456,7 +456,7 @@ mod tests { for (input, expected) in test_cases { let output = test_describe_with_limit(input, Limit::new(3), describe_identifier); - assert_eq!(output, expected, "Failed for input: {}", input); + assert_eq!(output, expected, "Failed for input: {input}"); } } @@ -470,7 +470,7 @@ mod tests { for (input, expected) in test_cases { let output = test_describe_with_limit(input, Limit::new(3), describe_string); - assert_eq!(output, expected, "Failed for input: {}", input); + assert_eq!(output, expected, "Failed for input: {input}"); } } } diff --git a/tests/src/find_protoc.rs b/tests/src/find_protoc.rs index a5e0ec1d..8f725d58 100644 --- a/tests/src/find_protoc.rs +++ b/tests/src/find_protoc.rs @@ -11,7 +11,7 @@ fn main() { { // Use vendored protobuf compiler if requested. protoc_path = protobuf_src::protoc(); - println!("cargo:warning=Using vendored protoc: {:?}", protoc_path); + println!("cargo:warning=Using vendored protoc: {protoc_path:?}"); } #[cfg(not(feature = "protoc"))] { From 4cc3b72110cf715d28a5494314b441190ed4738a Mon Sep 17 00:00:00 2001 From: Matthijs Brobbel Date: Mon, 30 Jun 2025 14:43:56 +0200 Subject: [PATCH 2/2] ci: use github token for buf setup action --- .github/workflows/proto.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index c64cffb3..fb6be823 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -14,6 +14,8 @@ jobs: with: submodules: recursive - uses: bufbuild/buf-setup-action@v1.50.0 + with: + github_token: ${{ github.token }} - run: buf format --diff --exit-code check: @@ -27,6 +29,8 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: bufbuild/buf-setup-action@v1.50.0 + with: + github_token: ${{ github.token }} - uses: bufbuild/buf-lint-action@v1.1.1 - name: Compile protobuf run: buf generate